svn commit: r201663 - stable/6/sys/netinet

Bjoern A. Zeeb bz at
Wed Jan 6 20:07:19 UTC 2010

Author: bz
Date: Wed Jan  6 20:07:18 2010
New Revision: 201663

  MFC r186948 (w/o the IPv6 parts):
    Make SIOCGIFADDR and related,
    jail-aware. Up to now we returned the first address of the interface
    for SIOCGIFADDR w/o an ifr_addr in the query. This caused problems for
    programs querying for an address but running inside a jail, as the
    address returned usually did not belong to the jail.
    If there was an ifr_addr given on v4, you could probe
    for more addresses on the interfaces that you were not allowed to see
    from inside a jail. Return an error (EADDRNOTAVAIL) in that case
    now unless the address is on the given interface and valid for the
  PR:		kern/114325
  Thanks to:	Axel Scheepers (axel.scheepers

Directory Properties:
  stable/6/sys/   (props changed)
  stable/6/sys/contrib/pf/   (props changed)
  stable/6/sys/dev/cxgb/   (props changed)

Modified: stable/6/sys/netinet/in.c
--- stable/6/sys/netinet/in.c	Wed Jan  6 20:04:36 2010	(r201662)
+++ stable/6/sys/netinet/in.c	Wed Jan  6 20:07:18 2010	(r201663)
@@ -38,7 +38,9 @@
 #include <sys/sockio.h>
 #include <sys/malloc.h>
 #include <sys/socket.h>
+#include <sys/jail.h>
 #include <sys/kernel.h>
+#include <sys/proc.h>
 #include <sys/sysctl.h>
 #include <net/if.h>
@@ -254,13 +256,19 @@ in_control(so, cmd, data, ifp, td)
 		LIST_FOREACH(iap, INADDR_HASH(dst.s_addr), ia_hash)
 			if (iap->ia_ifp == ifp &&
 			    iap->ia_addr.sin_addr.s_addr == dst.s_addr) {
-				ia = iap;
+				if (td == NULL || !prison_ip(
+				    td->td_ucred, 0, &dst.s_addr))
+					ia = iap;
 		if (ia == NULL)
 			TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
 				iap = ifatoia(ifa);
 				if (iap->ia_addr.sin_family == AF_INET) {
+					if (td != NULL &&
+					    prison_ip(td->td_ucred, 0,
+					    &iap->ia_addr.sin_addr.s_addr))
+						continue;
 					ia = iap;

More information about the svn-src-stable-6 mailing list