From owner-svn-src-projects@freebsd.org Sat Jun 25 22:44:37 2016 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A14B8B80EFC for ; Sat, 25 Jun 2016 22:44:37 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 594F71197; Sat, 25 Jun 2016 22:44:37 +0000 (UTC) (envelope-from bz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u5PMiaGl056861; Sat, 25 Jun 2016 22:44:36 GMT (envelope-from bz@FreeBSD.org) Received: (from bz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u5PMiaAg056859; Sat, 25 Jun 2016 22:44:36 GMT (envelope-from bz@FreeBSD.org) Message-Id: <201606252244.u5PMiaAg056859@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bz set sender to bz@FreeBSD.org using -f From: "Bjoern A. Zeeb" Date: Sat, 25 Jun 2016 22:44:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r302205 - projects/vnet/sys/contrib/ipfilter/netinet X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Jun 2016 22:44:37 -0000 Author: bz Date: Sat Jun 25 22:44:36 2016 New Revision: 302205 URL: https://svnweb.freebsd.org/changeset/base/302205 Log: Cover all of the ioctl handler with a set vnet; what was there from old days was not enough anymore. Also use curthread for read/write operations on the device, rather than the cache credentials; things can move around and the cached ones might not be the right ones. Sponsored by: The FreeBSD Foundation Modified: projects/vnet/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c projects/vnet/sys/contrib/ipfilter/netinet/mlfk_ipl.c Modified: projects/vnet/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c ============================================================================== --- projects/vnet/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Sat Jun 25 22:24:16 2016 (r302204) +++ projects/vnet/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c Sat Jun 25 22:44:36 2016 (r302205) @@ -298,10 +298,12 @@ ipfioctl(dev, cmd, data, mode int error = 0, unit = 0; SPL_INT(s); + CURVNET_SET(TD_TO_VNET(p)); #if (BSD >= 199306) if (securelevel_ge(p->p_cred, 3) && (mode & FWRITE)) { V_ipfmain.ipf_interror = 130001; + CURVNET_RESTORE(); return EPERM; } #endif @@ -309,12 +311,14 @@ ipfioctl(dev, cmd, data, mode unit = GET_MINOR(dev); if ((IPL_LOGMAX < unit) || (unit < 0)) { V_ipfmain.ipf_interror = 130002; + CURVNET_RESTORE(); return ENXIO; } if (V_ipfmain.ipf_running <= 0) { if (unit != IPL_LOGIPF && cmd != SIOCIPFINTERROR) { V_ipfmain.ipf_interror = 130003; + CURVNET_RESTORE(); return EIO; } if (cmd != SIOCIPFGETNEXT && cmd != SIOCIPFGET && @@ -322,13 +326,13 @@ ipfioctl(dev, cmd, data, mode cmd != SIOCGETFS && cmd != SIOCGETFF && cmd != SIOCIPFINTERROR) { V_ipfmain.ipf_interror = 130004; + CURVNET_RESTORE(); return EIO; } } SPL_NET(s); - CURVNET_SET(TD_TO_VNET(p)); error = ipf_ioctlswitch(&V_ipfmain, unit, data, cmd, mode, p->p_uid, p); CURVNET_RESTORE(); if (error != -1) { Modified: projects/vnet/sys/contrib/ipfilter/netinet/mlfk_ipl.c ============================================================================== --- projects/vnet/sys/contrib/ipfilter/netinet/mlfk_ipl.c Sat Jun 25 22:24:16 2016 (r302204) +++ projects/vnet/sys/contrib/ipfilter/netinet/mlfk_ipl.c Sat Jun 25 22:44:36 2016 (r302205) @@ -513,7 +513,7 @@ static int ipfread(dev, uio) if (unit < 0) return ENXIO; - CURVNET_SET(CRED_TO_VNET(dev->si_cred)); + CURVNET_SET(TD_TO_VNET(curthread)); if (V_ipfmain.ipf_running < 1) { CURVNET_RESTORE(); return EIO; @@ -556,7 +556,7 @@ static int ipfwrite(dev, uio) { int error; - CURVNET_SET(CRED_TO_VNET(dev->si_cred)); + CURVNET_SET(TD_TO_VNET(curthread)); if (V_ipfmain.ipf_running < 1) { CURVNET_RESTORE(); return EIO;