kern/99068: [linux] Linux emulator crashed by java, when calling ioctl(fd,SIOCGIFINDEX,...)

Marcin Cieslak saper at SYSTEM.PL
Sun Sep 10 13:20:37 PDT 2006


The following reply was made to PR kern/99068; it has been noted by GNATS.

From: Marcin Cieslak <saper at SYSTEM.PL>
To: bug-followup at FreeBSD.org, esepecesito at gmail.com
Cc: emulation at FreeBSD.org
Subject: Re: kern/99068: [linux] Linux emulator crashed by java, when calling
 ioctl(fd,SIOCGIFINDEX,...)
Date: Sun, 10 Sep 2006 22:18:13 +0200

 A quick patch for this as below (linux.h needs to patched
 for all architectures).
 
 --- linux.h	Sun Sep 10 22:03:28 2006
 +++ linux.h_new	Sun Sep 10 22:02:53 2006
 @@ -657,6 +657,7 @@
   		struct l_sockaddr	ifru_hwaddr;
   		l_short		ifru_flags[1];
   		l_int		ifru_metric;
 +		l_int		ifru_ivalue;
   		l_int		ifru_mtu;
   		struct l_ifmap	ifru_map;
   		char		ifru_slave[LINUX_IFNAMSIZ];
 @@ -666,6 +667,7 @@
 
   #define	ifr_name	ifr_ifrn.ifrn_name	/* interface name */
   #define	ifr_hwaddr	ifr_ifru.ifru_hwaddr	/* MAC address */
 +#define	ifr_ifindex	ifr_ifru.ifru_ivalue	/* Interface index */
 
   /*
    * poll()
 --- linux_ioctl.h	Sun Sep 10 22:05:48 2006
 +++ linux_ioctl.h_new	Sun Sep 10 22:05:32 2006
 @@ -196,9 +196,10 @@
   #define	LINUX_SIOCGIFHWADDR	0x8927
   #define	LINUX_SIOCADDMULTI	0x8931
   #define	LINUX_SIOCDELMULTI	0x8932
 +#define	LINUX_SIOCGIFINDEX	0x8933
 
   #define	LINUX_IOCTL_SOCKET_MIN	LINUX_FIOSETOWN
 -#define	LINUX_IOCTL_SOCKET_MAX	LINUX_SIOCDELMULTI
 +#define	LINUX_IOCTL_SOCKET_MAX	LINUX_SIOCGIFINDEX
 
   /*
    * Device private ioctl calls
 --- linux_ioctl.c	Sun Sep 10 22:05:48 2006
 +++ linux_ioctl.c_new	Sun Sep 10 22:08:24 2006
 @@ -2239,6 +2239,17 @@
   	return (copyout(&flags, &ifr->ifr_flags, sizeof(flags)));
   }
 
 +static int
 +linux_ifindex(struct thread *td, struct ifnet *ifp, struct l_ifreq *ifr)
 +{
 +#if DEBUG
 +	printf("Interface index: %d\n", ifp->if_index);
 +#endif
 +	l_int index;
 +	index = ifp->if_index;
 +	return (copyout(&index, &ifr->ifr_ifindex, sizeof(index)));
 +}
 +
   #define ARPHRD_ETHER	1
   #define ARPHRD_LOOPBACK	772
 
 @@ -2325,6 +2336,7 @@
   	case LINUX_SIOCSIFADDR:
   	case LINUX_SIOCGIFDSTADDR:
   	case LINUX_SIOCGIFBRDADDR:
 +	case LINUX_SIOCGIFINDEX:
   	case LINUX_SIOCGIFNETMASK:
   	case LINUX_SIOCSIFNETMASK:
   	case LINUX_SIOCGIFMTU:
 @@ -2421,6 +2433,11 @@
   	case LINUX_SIOCGIFBRDADDR:
   		args->cmd = OSIOCGIFBRDADDR;
   		error = ioctl(td, (struct ioctl_args *)args);
 +		break;
 +
 +	case LINUX_SIOCGIFINDEX:
 +		args->cmd = SIOCGIFINDEX;
 +		error = linux_ifindex(td, ifp, (struct l_ifreq *)args->arg);
   		break;
 
   	case LINUX_SIOCGIFNETMASK:
 
 -- 
                << Marcin Cieslak // saper at system.pl >>
 


More information about the freebsd-bugs mailing list