From owner-svn-src-stable-7@FreeBSD.ORG Sat Apr 9 10:22:18 2011 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92694106564A; Sat, 9 Apr 2011 10:22:18 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7F2028FC0A; Sat, 9 Apr 2011 10:22:18 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p39AMIbn008960; Sat, 9 Apr 2011 10:22:18 GMT (envelope-from bz@svn.freebsd.org) Received: (from bz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p39AMIER008957; Sat, 9 Apr 2011 10:22:18 GMT (envelope-from bz@svn.freebsd.org) Message-Id: <201104091022.p39AMIER008957@svn.freebsd.org> From: "Bjoern A. Zeeb" Date: Sat, 9 Apr 2011 10:22:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220477 - stable/7/sys/net X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Apr 2011 10:22:18 -0000 Author: bz Date: Sat Apr 9 10:22:18 2011 New Revision: 220477 URL: http://svn.freebsd.org/changeset/base/220477 Log: MFC r219206: Hide the outer IP addresses of a tunnel interfaces (gif(4), gre(4)) from processes inside jails if the addresses do not belong to the jail. Originally reported by: Pieter de Boer via remko Tested by: Piotr KUCHARSKI (nospam 42.pl) [gif] PR: kern/151119 Modified: stable/7/sys/net/if_gif.c stable/7/sys/net/if_gre.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/net/if_gif.c ============================================================================== --- stable/7/sys/net/if_gif.c Sat Apr 9 10:19:25 2011 (r220476) +++ stable/7/sys/net/if_gif.c Sat Apr 9 10:22:18 2011 (r220477) @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -811,6 +812,12 @@ gif_ioctl(ifp, cmd, data) } if (src->sa_len > size) return EINVAL; + error = prison_if(curthread->td_ucred, src); + if (error != 0) + return (error); + error = prison_if(curthread->td_ucred, dst); + if (error != 0) + return (error); bcopy((caddr_t)src, (caddr_t)dst, src->sa_len); #ifdef INET6 if (dst->sa_family == AF_INET6) { Modified: stable/7/sys/net/if_gre.c ============================================================================== --- stable/7/sys/net/if_gre.c Sat Apr 9 10:19:25 2011 (r220476) +++ stable/7/sys/net/if_gre.c Sat Apr 9 10:22:18 2011 (r220477) @@ -53,6 +53,7 @@ #include "opt_inet6.h" #include +#include #include #include #include @@ -642,6 +643,9 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, si.sin_len = sizeof(struct sockaddr_in); si.sin_addr.s_addr = sc->g_src.s_addr; sa = sintosa(&si); + error = prison_if(curthread->td_ucred, sa); + if (error != 0) + break; ifr->ifr_addr = *sa; break; case GREGADDRD: @@ -650,6 +654,9 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, si.sin_len = sizeof(struct sockaddr_in); si.sin_addr.s_addr = sc->g_dst.s_addr; sa = sintosa(&si); + error = prison_if(curthread->td_ucred, sa); + if (error != 0) + break; ifr->ifr_addr = *sa; break; case SIOCSIFPHYADDR: @@ -713,8 +720,14 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, si.sin_family = AF_INET; si.sin_len = sizeof(struct sockaddr_in); si.sin_addr.s_addr = sc->g_src.s_addr; + error = prison_if(curthread->td_ucred, (struct sockaddr *)&si); + if (error != 0) + break; memcpy(&lifr->addr, &si, sizeof(si)); si.sin_addr.s_addr = sc->g_dst.s_addr; + error = prison_if(curthread->td_ucred, (struct sockaddr *)&si); + if (error != 0) + break; memcpy(&lifr->dstaddr, &si, sizeof(si)); break; case SIOCGIFPSRCADDR: @@ -729,6 +742,9 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, si.sin_family = AF_INET; si.sin_len = sizeof(struct sockaddr_in); si.sin_addr.s_addr = sc->g_src.s_addr; + error = prison_if(curthread->td_ucred, (struct sockaddr *)&si); + if (error != 0) + break; bcopy(&si, &ifr->ifr_addr, sizeof(ifr->ifr_addr)); break; case SIOCGIFPDSTADDR: @@ -743,6 +759,9 @@ gre_ioctl(struct ifnet *ifp, u_long cmd, si.sin_family = AF_INET; si.sin_len = sizeof(struct sockaddr_in); si.sin_addr.s_addr = sc->g_dst.s_addr; + error = prison_if(curthread->td_ucred, (struct sockaddr *)&si); + if (error != 0) + break; bcopy(&si, &ifr->ifr_addr, sizeof(ifr->ifr_addr)); break; case GRESKEY: