From nobody@FreeBSD.org  Sat Mar  3 01:03:54 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 2E922106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  3 Mar 2012 01:03:54 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 1E6D08FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Sat,  3 Mar 2012 01:03:54 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q2313r2X006759
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 3 Mar 2012 01:03:53 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q2313rn5006741;
	Sat, 3 Mar 2012 01:03:53 GMT
	(envelope-from nobody)
Message-Id: <201203030103.q2313rn5006741@red.freebsd.org>
Date: Sat, 3 Mar 2012 01:03:53 GMT
From: Vijay Singh <vijju.singh@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Missing vnet restores in net/if_ethersubr.c
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         165643
>Category:       kern
>Synopsis:       [net] [patch] Missing vnet restores in net/if_ethersubr.c
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-net
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 03 01:10:08 UTC 2012
>Closed-Date:    Sat May 18 16:26:13 UTC 2013
>Last-Modified:  Sat May 18 16:26:13 UTC 2013
>Originator:     Vijay Singh
>Release:        9/stable
>Organization:
>Environment:
>Description:
There are some missing vnet restore in net/if_ethersubr.c that can cause
networking code to execute in the wrong vnet context.

A patch is provided here:

[pc20 /u/vijay/bsd/CODE/9s/sys]# svn diff net/if_ethersubr.c
Index: net/if_ethersubr.c
===================================================================
--- net/if_ethersubr.c  (revision 232242)
+++ net/if_ethersubr.c  (working copy)
@@ -661,8 +661,10 @@
              m = (*lagg_input_p)(ifp, m);
              if (m != NULL)
                      ifp = m->m_pkthdr.rcvif;
-               else
+               else {
+                       CURVNET_RESTORE();
                      return;
+               }
      }

      /*
@@ -681,6 +683,7 @@
 #endif
                      ifp->if_ierrors++;
                      m_freem(m);
+                       CURVNET_RESTORE();
                      return;
              }
>How-To-Repeat:

>Fix:
[pc20 /u/vijay/bsd/CODE/9s/sys]# svn diff net/if_ethersubr.c
Index: net/if_ethersubr.c
===================================================================
--- net/if_ethersubr.c  (revision 232242)
+++ net/if_ethersubr.c  (working copy)
@@ -661,8 +661,10 @@
              m = (*lagg_input_p)(ifp, m);
              if (m != NULL)
                      ifp = m->m_pkthdr.rcvif;
-               else
+               else {
+                       CURVNET_RESTORE();
                      return;
+               }
      }

      /*
@@ -681,6 +683,7 @@
 #endif
                      ifp->if_ierrors++;
                      m_freem(m);
+                       CURVNET_RESTORE();
                      return;
              }

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Mar 4 02:35:34 UTC 2012 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165643 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/165643: commit references a PR
Date: Sun,  4 Mar 2012 11:11:45 +0000 (UTC)

 Author: zec
 Date: Sun Mar  4 11:11:03 2012
 New Revision: 232487
 URL: http://svn.freebsd.org/changeset/base/232487
 
 Log:
   Properly restore curvnet context when returning early from
   ether_input_internal().
   
   This change only affects options VIMAGE kernel builds.
   
   PR:		kern/165643
   Submitted by:	Vijay Singh
   MFC after:	3 days
 
 Modified:
   head/sys/net/if_ethersubr.c
 
 Modified: head/sys/net/if_ethersubr.c
 ==============================================================================
 --- head/sys/net/if_ethersubr.c	Sun Mar  4 10:37:26 2012	(r232486)
 +++ head/sys/net/if_ethersubr.c	Sun Mar  4 11:11:03 2012	(r232487)
 @@ -661,8 +661,10 @@ ether_input_internal(struct ifnet *ifp, 
  		m = (*lagg_input_p)(ifp, m);
  		if (m != NULL)
  			ifp = m->m_pkthdr.rcvif;
 -		else 
 +		else {
 +			CURVNET_RESTORE();
  			return;
 +		}
  	}
  
  	/*
 @@ -681,6 +683,7 @@ ether_input_internal(struct ifnet *ifp, 
  #endif
  			ifp->if_ierrors++;
  			m_freem(m);
 +			CURVNET_RESTORE();
  			return;
  		}
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/165643: commit references a PR
Date: Wed, 28 Mar 2012 12:40:41 +0000 (UTC)

 Author: zec
 Date: Wed Mar 28 12:40:30 2012
 New Revision: 233602
 URL: http://svn.freebsd.org/changeset/base/233602
 
 Log:
   MFC: 232487
     Properly restore curvnet context when returning early from
     ether_input_internal().
   
     This change only affects options VIMAGE kernel builds.
   
     PR:           kern/165643
     Submitted by: Vijay Singh
     MFC after:    3 days
 
 Modified:
   stable/9/sys/net/if_ethersubr.c
 Directory Properties:
   stable/9/sys/   (props changed)
   stable/9/sys/amd64/include/xen/   (props changed)
   stable/9/sys/boot/   (props changed)
   stable/9/sys/boot/i386/efi/   (props changed)
   stable/9/sys/boot/ia64/efi/   (props changed)
   stable/9/sys/boot/ia64/ski/   (props changed)
   stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
   stable/9/sys/boot/powerpc/ofw/   (props changed)
   stable/9/sys/cddl/contrib/opensolaris/   (props changed)
   stable/9/sys/conf/   (props changed)
   stable/9/sys/contrib/dev/acpica/   (props changed)
   stable/9/sys/contrib/octeon-sdk/   (props changed)
   stable/9/sys/contrib/pf/   (props changed)
   stable/9/sys/contrib/x86emu/   (props changed)
   stable/9/sys/fs/   (props changed)
   stable/9/sys/fs/ntfs/   (props changed)
   stable/9/sys/i386/conf/XENHVM   (props changed)
 
 Modified: stable/9/sys/net/if_ethersubr.c
 ==============================================================================
 --- stable/9/sys/net/if_ethersubr.c	Wed Mar 28 12:30:16 2012	(r233601)
 +++ stable/9/sys/net/if_ethersubr.c	Wed Mar 28 12:40:30 2012	(r233602)
 @@ -661,8 +661,10 @@ ether_input_internal(struct ifnet *ifp, 
  		m = (*lagg_input_p)(ifp, m);
  		if (m != NULL)
  			ifp = m->m_pkthdr.rcvif;
 -		else 
 +		else {
 +			CURVNET_RESTORE();
  			return;
 +		}
  	}
  
  	/*
 @@ -681,6 +683,7 @@ ether_input_internal(struct ifnet *ifp, 
  #endif
  			ifp->if_ierrors++;
  			m_freem(m);
 +			CURVNET_RESTORE();
  			return;
  		}
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/165643: commit references a PR
Date: Wed, 28 Mar 2012 12:41:36 +0000 (UTC)

 Author: zec
 Date: Wed Mar 28 12:41:17 2012
 New Revision: 233603
 URL: http://svn.freebsd.org/changeset/base/233603
 
 Log:
   MFC 232487:
     Properly restore curvnet context when returning early from
     ether_input_internal().
   
     This change only affects options VIMAGE kernel builds.
   
     PR:           kern/165643
     Submitted by: Vijay Singh
     MFC after:    3 days
 
 Modified:
   stable/8/sys/net/if_ethersubr.c
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/boot/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/e1000/   (props changed)
   stable/8/sys/i386/conf/XENHVM   (props changed)
 
 Modified: stable/8/sys/net/if_ethersubr.c
 ==============================================================================
 --- stable/8/sys/net/if_ethersubr.c	Wed Mar 28 12:40:30 2012	(r233602)
 +++ stable/8/sys/net/if_ethersubr.c	Wed Mar 28 12:41:17 2012	(r233603)
 @@ -660,8 +660,10 @@ ether_input(struct ifnet *ifp, struct mb
  		m = (*lagg_input_p)(ifp, m);
  		if (m != NULL)
  			ifp = m->m_pkthdr.rcvif;
 -		else 
 +		else {
 +			CURVNET_RESTORE();
  			return;
 +		}
  	}
  
  	/*
 @@ -680,6 +682,7 @@ ether_input(struct ifnet *ifp, struct mb
  #endif
  			ifp->if_ierrors++;
  			m_freem(m);
 +			CURVNET_RESTORE();
  			return;
  		}
  
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: trociny 
State-Changed-When: Sat May 18 16:25:35 UTC 2013 
State-Changed-Why:  
Committed. Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=165643 
>Unformatted:
