Date: Wed, 6 Jan 2010 20:07:18 +0000 (UTC) From: "Bjoern A. Zeeb" <bz@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-6@freebsd.org Subject: svn commit: r201663 - stable/6/sys/netinet Message-ID: <201001062007.o06K7IlA026014@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bz Date: Wed Jan 6 20:07:18 2010 New Revision: 201663 URL: http://svn.freebsd.org/changeset/base/201663 Log: 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 jail. PR: kern/114325 Thanks to: Axel Scheepers (axel.scheepers nl.clara.net) Modified: stable/6/sys/netinet/in.c 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; 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_ip(td->td_ucred, 0, + &iap->ia_addr.sin_addr.s_addr)) + continue; ia = iap; break; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001062007.o06K7IlA026014>