From nobody@FreeBSD.org  Sun Mar 24 00:45:13 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	by hub.freebsd.org (Postfix) with ESMTP id 644D1698
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Mar 2013 00:45:13 +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 56A322DB
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Mar 2013 00:45:13 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r2O0jDrx067322
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 24 Mar 2013 00:45:13 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.5/8.14.5/Submit) id r2O0jDp9067321;
	Sun, 24 Mar 2013 00:45:13 GMT
	(envelope-from nobody)
Message-Id: <201303240045.r2O0jDp9067321@red.freebsd.org>
Date: Sun, 24 Mar 2013 00:45:13 GMT
From: anonymous <anonymous@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [jail] Jail umounts fstab in the wrong order
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         177325
>Category:       kern
>Synopsis:       [jail] Jail umounts fstab in the wrong order
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    jamie
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Mar 24 00:50:00 UTC 2013
>Closed-Date:    Sun Mar 31 04:11:19 UTC 2013
>Last-Modified:  Sun Mar 31 04:20:00 UTC 2013
>Originator:     anonymous
>Release:        FreeBSD 9.1-RELEASE i386
>Organization:
>Environment:
FreeBSD FreeBSD 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Thu Jan 24 01:27:54 PST 2013     root@SwordFish:/usr/obj/usr/src/sys/CUSTOM  i386
>Description:
The jail command doesn't reverse the order of fstab when dismounting.
>How-To-Repeat:
# cat /etc/jail.conf
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
mount.devfs;

path = "/jails/${name}";
mount.fstab = "/etc/fstab.${name}";
host.hostname = "${name}.FreeBSD";



build {
  interface = "fxp0";
  ip4.addr = "10.0.0.1";
  allow.raw_sockets;
}

# cat /etc/fstab.build 
/usr/ports		/jails/build/usr/ports			nullfs	rw,noatime	0	0
/usr/ports/distfiles	/jails/build/usr/ports/distfiles	nullfs	rw,noatime	0	0
/usr/ports/packages	/jails/build/usr/ports/packages		nullfs	rw,noatime	0	0
/usr/src		/jails/build/usr/src			nullfs	ro,noatime	0	0

# jail -cv build
build: run command: /sbin/ifconfig fxp0 inet 10.0.0.1 netmask 255.255.255.255 alias
build: run command: /sbin/mount -t nullfs -o rw,noatime /usr/ports /jails/build/usr/ports
build: run command: /sbin/mount -t nullfs -o rw,noatime /usr/ports/distfiles /jails/build/usr/ports/distfiles
build: run command: /sbin/mount -t nullfs -o rw,noatime /usr/ports/packages /jails/build/usr/ports/packages
build: run command: /sbin/mount -t nullfs -o ro,noatime /usr/src /jails/build/usr/src
build: run command: /sbin/mount -t devfs -oruleset=4 . /jails/build/dev
build: jail_set(JAIL_CREATE) persist name=build path=/jails/build host.hostname=build.FreeBSD ip4.addr=10.0.0.1 allow.raw_sockets
build: created
build: run command in jail: /bin/sh /etc/rc
/etc/rc: WARNING: $hostname is not set -- see rc.conf(5).
Creating and/or trimming log files.
ln: /dev/log: Operation not permitted
Starting syslogd.
ELF ldconfig path: /lib /usr/lib /usr/lib/compat
a.out ldconfig path: /usr/lib/aout /usr/lib/compat/aout
Clearing /tmp (X related).
Updating motd:.
Starting cron.

Sat Mar 23 17:36:46 PDT 2013
build: jail_set(JAIL_UPDATE) jid=6 nopersist
# jail -rv build
build: run command in jail: /bin/sh /etc/rc.shutdown
Stopping cron.
Waiting for PIDS: 3874.
Terminated
>Fix:
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-jail 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sun Mar 24 01:15:19 UTC 2013 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=177325 
State-Changed-From-To: open->patched 
State-Changed-By: jamie 
State-Changed-When: Thu Mar 28 21:05:25 UTC 2013 
State-Changed-Why:  
CURRENT patched in r248854 


Responsible-Changed-From-To: freebsd-jail->jamie 
Responsible-Changed-By: jamie 
Responsible-Changed-When: Thu Mar 28 21:05:25 UTC 2013 
Responsible-Changed-Why:  

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/177325: commit references a PR
Date: Thu, 28 Mar 2013 21:02:56 +0000 (UTC)

 Author: jamie
 Date: Thu Mar 28 21:02:49 2013
 New Revision: 248854
 URL: http://svnweb.freebsd.org/changeset/base/248854
 
 Log:
   Reverse the order of some implicit commands (FS mounts and ifconfigs)
   when stopping jails.  This matters particularly for nested filesystem
   mounts.
   
   PR:		kern/177325
   Submitted by:	Harald Schmalzbauer
   MFC after:	3 days
 
 Modified:
   head/usr.sbin/jail/command.c
   head/usr.sbin/jail/config.c
   head/usr.sbin/jail/jailp.h
 
 Modified: head/usr.sbin/jail/command.c
 ==============================================================================
 --- head/usr.sbin/jail/command.c	Thu Mar 28 20:48:58 2013	(r248853)
 +++ head/usr.sbin/jail/command.c	Thu Mar 28 21:02:49 2013	(r248854)
 @@ -88,13 +88,14 @@ int
  next_command(struct cfjail *j)
  {
  	enum intparam comparam;
 -	int create_failed;
 +	int create_failed, stopping;
  
  	if (paralimit == 0) {
  		requeue(j, &runnable);
  		return 1;
  	}
  	create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
 +	stopping = (j->flags & JF_STOP) != 0;
  	comparam = *j->comparam;
  	for (;;) {
  		if (j->comstring == NULL) {
 @@ -113,14 +114,16 @@ next_command(struct cfjail *j)
  			default:
  				if (j->intparams[comparam] == NULL)
  					continue;
 -				j->comstring = create_failed
 +				j->comstring = create_failed || (stopping &&
 +				    (j->intparams[comparam]->flags & PF_REV))
  				    ? TAILQ_LAST(&j->intparams[comparam]->val,
  					cfstrings)
  				    : TAILQ_FIRST(&j->intparams[comparam]->val);
  			}
  		} else {
  			j->comstring = j->comstring == &dummystring ? NULL :
 -			    create_failed
 +			    create_failed || (stopping &&
 +			    (j->intparams[comparam]->flags & PF_REV))
  			    ? TAILQ_PREV(j->comstring, cfstrings, tq)
  			    : TAILQ_NEXT(j->comstring, tq);
  		}
 
 Modified: head/usr.sbin/jail/config.c
 ==============================================================================
 --- head/usr.sbin/jail/config.c	Thu Mar 28 20:48:58 2013	(r248853)
 +++ head/usr.sbin/jail/config.c	Thu Mar 28 21:02:49 2013	(r248854)
 @@ -81,18 +81,18 @@ static const struct ipspec intparams[] =
      [IP_INTERFACE] =		{"interface",		PF_INTERNAL},
      [IP_IP_HOSTNAME] =		{"ip_hostname",		PF_INTERNAL | PF_BOOL},
  #endif
 -    [IP_MOUNT] =		{"mount",		PF_INTERNAL},
 +    [IP_MOUNT] =		{"mount",		PF_INTERNAL | PF_REV},
      [IP_MOUNT_DEVFS] =		{"mount.devfs",		PF_INTERNAL | PF_BOOL},
      [IP_MOUNT_FSTAB] =		{"mount.fstab",		PF_INTERNAL},
      [IP_STOP_TIMEOUT] =		{"stop.timeout",	PF_INTERNAL | PF_INT},
      [IP_VNET_INTERFACE] =	{"vnet.interface",	PF_INTERNAL},
  #ifdef INET
 -    [IP__IP4_IFADDR] =		{"ip4.addr",		PF_INTERNAL | PF_CONV},
 +    [IP__IP4_IFADDR] =		{"ip4.addr",	PF_INTERNAL | PF_CONV | PF_REV},
  #endif
  #ifdef INET6
 -    [IP__IP6_IFADDR] =		{"ip6.addr",		PF_INTERNAL | PF_CONV},
 +    [IP__IP6_IFADDR] =		{"ip6.addr",	PF_INTERNAL | PF_CONV | PF_REV},
  #endif
 -    [IP__MOUNT_FROM_FSTAB] =	{"mount.fstab",		PF_INTERNAL | PF_CONV},
 +    [IP__MOUNT_FROM_FSTAB] =	{"mount.fstab",	PF_INTERNAL | PF_CONV | PF_REV},
      [IP__OP] =			{NULL,			PF_CONV},
      [KP_ALLOW_CHFLAGS] =	{"allow.chflags",	0},
      [KP_ALLOW_MOUNT] =		{"allow.mount",		0},
 
 Modified: head/usr.sbin/jail/jailp.h
 ==============================================================================
 --- head/usr.sbin/jail/jailp.h	Thu Mar 28 20:48:58 2013	(r248853)
 +++ head/usr.sbin/jail/jailp.h	Thu Mar 28 21:02:49 2013	(r248854)
 @@ -50,6 +50,7 @@
  #define PF_BOOL		0x10	/* Boolean parameter */
  #define PF_INT		0x20	/* Integer parameter */
  #define PF_CONV		0x40	/* Parameter duplicated in converted form */
 +#define PF_REV		0x80	/* Run commands in reverse order on stopping */
  
  #define JF_START	0x0001	/* -c */
  #define JF_SET		0x0002	/* -m */
 _______________________________________________
 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: patched->closed 
State-Changed-By: jamie 
State-Changed-When: Sun Mar 31 04:10:57 UTC 2013 
State-Changed-Why:  
MFC in r248939 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/177325: commit references a PR
Date: Sun, 31 Mar 2013 04:10:51 +0000 (UTC)

 Author: jamie
 Date: Sun Mar 31 04:10:37 2013
 New Revision: 248939
 URL: http://svnweb.freebsd.org/changeset/base/248939
 
 Log:
   MFC r248854:
   
     Reverse the order of some implicit commands (FS mounts and ifconfigs)
     when stopping jails.  This matters particularly for nested filesystem
     mounts.
   
   PR:		kern/177325
   Submitted by:	Harald Schmalzbauer
 
 Modified:
   stable/9/usr.sbin/jail/command.c
   stable/9/usr.sbin/jail/config.c
   stable/9/usr.sbin/jail/jailp.h
 Directory Properties:
   stable/9/usr.sbin/jail/   (props changed)
 
 Modified: stable/9/usr.sbin/jail/command.c
 ==============================================================================
 --- stable/9/usr.sbin/jail/command.c	Sun Mar 31 03:56:48 2013	(r248938)
 +++ stable/9/usr.sbin/jail/command.c	Sun Mar 31 04:10:37 2013	(r248939)
 @@ -88,13 +88,14 @@ int
  next_command(struct cfjail *j)
  {
  	enum intparam comparam;
 -	int create_failed;
 +	int create_failed, stopping;
  
  	if (paralimit == 0) {
  		requeue(j, &runnable);
  		return 1;
  	}
  	create_failed = (j->flags & (JF_STOP | JF_FAILED)) == JF_FAILED;
 +	stopping = (j->flags & JF_STOP) != 0;
  	comparam = *j->comparam;
  	for (;;) {
  		if (j->comstring == NULL) {
 @@ -113,14 +114,16 @@ next_command(struct cfjail *j)
  			default:
  				if (j->intparams[comparam] == NULL)
  					continue;
 -				j->comstring = create_failed
 +				j->comstring = create_failed || (stopping &&
 +				    (j->intparams[comparam]->flags & PF_REV))
  				    ? TAILQ_LAST(&j->intparams[comparam]->val,
  					cfstrings)
  				    : TAILQ_FIRST(&j->intparams[comparam]->val);
  			}
  		} else {
  			j->comstring = j->comstring == &dummystring ? NULL :
 -			    create_failed
 +			    create_failed || (stopping &&
 +			    (j->intparams[comparam]->flags & PF_REV))
  			    ? TAILQ_PREV(j->comstring, cfstrings, tq)
  			    : TAILQ_NEXT(j->comstring, tq);
  		}
 
 Modified: stable/9/usr.sbin/jail/config.c
 ==============================================================================
 --- stable/9/usr.sbin/jail/config.c	Sun Mar 31 03:56:48 2013	(r248938)
 +++ stable/9/usr.sbin/jail/config.c	Sun Mar 31 04:10:37 2013	(r248939)
 @@ -79,18 +79,18 @@ static const struct ipspec intparams[] =
      [IP_INTERFACE] =		{"interface",		PF_INTERNAL},
      [IP_IP_HOSTNAME] =		{"ip_hostname",		PF_INTERNAL | PF_BOOL},
  #endif
 -    [IP_MOUNT] =		{"mount",		PF_INTERNAL},
 +    [IP_MOUNT] =		{"mount",		PF_INTERNAL | PF_REV},
      [IP_MOUNT_DEVFS] =		{"mount.devfs",		PF_INTERNAL | PF_BOOL},
      [IP_MOUNT_FSTAB] =		{"mount.fstab",		PF_INTERNAL},
      [IP_STOP_TIMEOUT] =		{"stop.timeout",	PF_INTERNAL | PF_INT},
      [IP_VNET_INTERFACE] =	{"vnet.interface",	PF_INTERNAL},
  #ifdef INET
 -    [IP__IP4_IFADDR] =		{"ip4.addr",		PF_INTERNAL | PF_CONV},
 +    [IP__IP4_IFADDR] =		{"ip4.addr",	PF_INTERNAL | PF_CONV | PF_REV},
  #endif
  #ifdef INET6
 -    [IP__IP6_IFADDR] =		{"ip6.addr",		PF_INTERNAL | PF_CONV},
 +    [IP__IP6_IFADDR] =		{"ip6.addr",	PF_INTERNAL | PF_CONV | PF_REV},
  #endif
 -    [IP__MOUNT_FROM_FSTAB] =	{"mount.fstab",		PF_INTERNAL | PF_CONV},
 +    [IP__MOUNT_FROM_FSTAB] =	{"mount.fstab",	PF_INTERNAL | PF_CONV | PF_REV},
      [IP__OP] =			{NULL,			PF_CONV},
      [KP_ALLOW_CHFLAGS] =	{"allow.chflags",	0},
      [KP_ALLOW_MOUNT] =		{"allow.mount",		0},
 
 Modified: stable/9/usr.sbin/jail/jailp.h
 ==============================================================================
 --- stable/9/usr.sbin/jail/jailp.h	Sun Mar 31 03:56:48 2013	(r248938)
 +++ stable/9/usr.sbin/jail/jailp.h	Sun Mar 31 04:10:37 2013	(r248939)
 @@ -50,6 +50,7 @@
  #define PF_BOOL		0x10	/* Boolean parameter */
  #define PF_INT		0x20	/* Integer parameter */
  #define PF_CONV		0x40	/* Parameter duplicated in converted form */
 +#define PF_REV		0x80	/* Run commands in reverse order on stopping */
  
  #define JF_START	0x0001	/* -c */
  #define JF_SET		0x0002	/* -m */
 _______________________________________________
 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"
 
>Unformatted:
