Problems with Samba -- svn commit: r186948 - in head/sys: netinet netinet6 (fwd)

Bjoern A. Zeeb bzeeb-lists at lists.zabbadoz.net
Fri Jan 9 13:15:07 UTC 2009


Hi,

in case anyone had trouble for example with Samba inside a jail
(and had to set interfaces = ...) you may want to update to this on
HEAD or grab the patch form the PR if you are running the multi-IP
jail patch. I'll include this in the next (upcoming) patchset.

/bz

-- 
Bjoern A. Zeeb                      The greatest risk is not taking one.

---------- Forwarded message ----------
Date: Fri, 9 Jan 2009 13:06:57 +0000 (UTC)
From: Bjoern A. Zeeb <bz at FreeBSD.org>
To: src-committers at freebsd.org, svn-src-all at freebsd.org,
     svn-src-head at freebsd.org
Subject: svn commit: r186948 - in head/sys: netinet netinet6

Author: bz
Date: Fri Jan  9 13:06:56 2009
New Revision: 186948
URL: http://svn.freebsd.org/changeset/base/186948

Log:
   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
   Reviewed by:	rwatson
   MFC after:	4 weeks

Modified:
   head/sys/netinet/in.c
   head/sys/netinet6/in6.c

Modified: head/sys/netinet/in.c
==============================================================================
--- head/sys/netinet/in.c	Fri Jan  9 12:38:41 2009	(r186947)
+++ head/sys/netinet/in.c	Fri Jan  9 13:06:56 2009	(r186948)
@@ -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 <sys/vimage.h>

@@ -261,13 +263,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: head/sys/netinet6/in6.c
==============================================================================
--- head/sys/netinet6/in6.c	Fri Jan  9 12:38:41 2009	(r186947)
+++ head/sys/netinet6/in6.c	Fri Jan  9 13:06:56 2009	(r186948)
@@ -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>
@@ -329,6 +330,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 freebsd-jail mailing list