From owner-freebsd-current@FreeBSD.ORG Tue Sep 2 22:59:26 2014 Return-Path: Delivered-To: freebsd-current@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AE585DA for ; Tue, 2 Sep 2014 22:59:26 +0000 (UTC) Received: from mail.ignoranthack.me (ignoranthack.me [199.102.79.106]) (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 8EDA710B2 for ; Tue, 2 Sep 2014 22:59:26 +0000 (UTC) Received: from [192.168.200.205] (unknown [50.136.155.142]) (using SSLv3 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: sbruno@ignoranthack.me) by mail.ignoranthack.me (Postfix) with ESMTPSA id B521B192906 for ; Tue, 2 Sep 2014 22:59:18 +0000 (UTC) Subject: [PATCH]Modify do_exec() handler to deal with multiple imgact handlers From: Sean Bruno Reply-To: sbruno@freebsd.org To: freebsd-current Content-Type: text/plain; charset="us-ascii" Date: Tue, 02 Sep 2014 15:59:17 -0700 Message-ID: <1409698757.55485.8.camel@bruno> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit 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: Tue, 02 Sep 2014 22:59:26 -0000 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 */ char opened; /* flag - we have opened executable vnode */ char *interpreter_name; /* name of the interpreter */ void *auxargs; /* ELF Auxinfo structure pointer */