svn commit: r188285 - in stable/7/sys: . contrib/pf dev/ath/ath_hal dev/cxgb netinet netinet6

Bjoern A. Zeeb bz at FreeBSD.org
Sat Feb 7 05:51:17 PST 2009


Author: bz
Date: Sat Feb  7 13:51:15 2009
New Revision: 188285
URL: http://svn.freebsd.org/changeset/base/188285

Log:
  MFC: r186948
  
    Make SIOCGIFADDR and related, as well as SIOCGIFADDR_IN6 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.
    Like for v6, 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
    jail.
  
    PR:		kern/114325

Modified:
  stable/7/sys/   (props changed)
  stable/7/sys/contrib/pf/   (props changed)
  stable/7/sys/dev/ath/ath_hal/   (props changed)
  stable/7/sys/dev/cxgb/   (props changed)
  stable/7/sys/netinet/in.c
  stable/7/sys/netinet6/in6.c

Modified: stable/7/sys/netinet/in.c
==============================================================================
--- stable/7/sys/netinet/in.c	Sat Feb  7 13:46:51 2009	(r188284)
+++ stable/7/sys/netinet/in.c	Sat Feb  7 13:51:15 2009	(r188285)
@@ -41,7 +41,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/malloc.h>
 #include <sys/priv.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>
@@ -252,13 +254,19 @@ in_control(struct socket *so, u_long cmd
 		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_check_ip4(
+				    td->td_ucred, &dst))
+					ia = iap;
 				break;
 			}
 		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_check_ip4(td->td_ucred,
+					    &iap->ia_addr.sin_addr))
+						continue;
 					ia = iap;
 					break;
 				}

Modified: stable/7/sys/netinet6/in6.c
==============================================================================
--- stable/7/sys/netinet6/in6.c	Sat Feb  7 13:46:51 2009	(r188284)
+++ stable/7/sys/netinet6/in6.c	Sat Feb  7 13:51:15 2009	(r188285)
@@ -68,6 +68,7 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
 #include <sys/errno.h>
+#include <sys/jail.h>
 #include <sys/malloc.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
@@ -468,6 +469,9 @@ in6_control(struct socket *so, u_long cm
 			error = in6_setscope(&sa6->sin6_addr, ifp, NULL);
 		if (error != 0)
 			return (error);
+		if (td != NULL && !prison_check_ip6(td->td_ucred,
+		    &sa6->sin6_addr))
+			return (EADDRNOTAVAIL);
 		ia = in6ifa_ifpwithaddr(ifp, &sa6->sin6_addr);
 	} else
 		ia = NULL;


More information about the svn-src-stable mailing list