From owner-freebsd-current@FreeBSD.ORG Wed Sep 3 20:06:28 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 12410C61; Wed, 3 Sep 2014 20:06:28 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id DF0E31D8B; Wed, 3 Sep 2014 20:06:27 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-70-85-31.nwrknj.fios.verizon.net [173.70.85.31]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AE2EEB984; Wed, 3 Sep 2014 16:06:26 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org, sbruno@freebsd.org Subject: Re: [PATCH]Modify do_exec() handler to deal with multiple imgact handlers Date: Wed, 03 Sep 2014 15:39:04 -0400 Message-ID: <1737767.X0j5Yf1ak8@ralph.baldwin.cx> User-Agent: KMail/4.10.5 (FreeBSD/10.0-STABLE; KDE/4.10.5; amd64; ; ) In-Reply-To: <1409698757.55485.8.camel@bruno> References: <1409698757.55485.8.camel@bruno> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 03 Sep 2014 16:06:26 -0400 (EDT) Cc: freebsd-current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Sep 2014 20:06:28 -0000 On Tuesday, September 02, 2014 03:59:17 PM Sean Bruno wrote: > https://reviews.freebsd.org/D696 > > I found that the binmisc handler was not executing if the shell handler > fired. Both were using the same intepreted flag to determine if they > should run. > > This change modifies struct image_params.interpreted to be a bitfield > instead of a bool flag and assigns one bit to each image activator. > > Comments? > > sean > > Index: sys/kern/imgact_binmisc.c > =================================================================== > --- sys/kern/imgact_binmisc.c > +++ sys/kern/imgact_binmisc.c > @@ -600,12 +600,12 @@ > } > > /* No interpreter nesting allowed. */ > - if (imgp->interpreted) { > + if (imgp->interpreted & IMGACT_BINMISC) { > mtx_unlock(&interp_list_mtx); > return (ENOEXEC); > } > > - imgp->interpreted = 1; > + imgp->interpreted |= IMGACT_BINMISC; > > if (imgp->args->fname != NULL) { > fname = imgp->args->fname; > Index: sys/kern/imgact_shell.c > =================================================================== > --- sys/kern/imgact_shell.c > +++ sys/kern/imgact_shell.c > @@ -115,10 +115,10 @@ > * Don't allow a shell script to be the shell for a shell > * script. :-) > */ > - if (imgp->interpreted) > + if (imgp->interpreted & IMGACT_SHELL) > return (ENOEXEC); > > - imgp->interpreted = 1; > + imgp->interpreted |= IMGACT_SHELL; > > /* > * At this point we have the first page of the file mapped. > Index: sys/sys/imgact.h > =================================================================== > --- sys/sys/imgact.h > +++ sys/sys/imgact.h > @@ -61,7 +61,9 @@ > unsigned long entry_addr; /* entry address of target executable */ > unsigned long reloc_base; /* load address of image */ > char vmspace_destroyed; /* flag - we've blown away original vm space */ > - char interpreted; /* flag - this executable is interpreted */ > +#define IMGACT_SHELL 0x1 > +#define IMGACT_BINMISC 0x2 > + unsigned char interpreted; /* mask of interpretes that have run */ s/interpretes/interpreters/ Other than that I think this is fine, though I wonder if it will result in some unexpected effects (you probably want to be able to use a binmisc binary as the #! interpreter for a script, but I'm not sure the opposite is true. -- John Baldwin