Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756166AbYKGXdb (ORCPT ); Fri, 7 Nov 2008 18:33:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754376AbYKGX0u (ORCPT ); Fri, 7 Nov 2008 18:26:50 -0500 Received: from kroah.org ([198.145.64.141]:47542 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754097AbYKGX0s (ORCPT ); Fri, 7 Nov 2008 18:26:48 -0500 Date: Fri, 7 Nov 2008 15:26:10 -0800 From: Greg KH To: linux-kernel@vger.kernel.org, stable@kernel.org Cc: Justin Forbes , Zwane Mwaikambo , "Theodore Ts'o" , Randy Dunlap , Dave Jones , Chuck Wolber , Chris Wedgwood , Michael Krufky , Chuck Ebbert , Domenico Andreoli , Willy Tarreau , Rodrigo Rubira Branco , Jake Edge , Eugene Teo , torvalds@linux-foundation.org, akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk, Serge Hallyn , David Howells , "Andrew G. Morgan" Subject: [patch 06/16] file caps: always start with clear bprm->caps_* Message-ID: <20081107232610.GG4282@kroah.com> References: <20081107231848.995297975@mini.kroah.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename="file-caps-always-start-with-clear-bprm-caps_.patch" In-Reply-To: <20081107232544.GA4282@kroah.com> User-Agent: Mutt/1.5.16 (2007-06-09) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1646 Lines: 50 2.6.25-stable review patch. If anyone has any objections, please let us know. ------------------ From: Serge Hallyn commit 3318a386e4ca68c76e0294363d29bdc46fcad670 upstream While Linux doesn't honor setuid on scripts. However, it mistakenly behaves differently for file capabilities. This patch fixes that behavior by making sure that get_file_caps() begins with empty bprm->caps_*. That way when a script is loaded, its bprm->caps_* may be filled when binfmt_misc calls prepare_binprm(), but they will be cleared again when binfmt_elf calls prepare_binprm() next to read the interpreter's file capabilities. Signed-off-by: Serge Hallyn Acked-by: David Howells Acked-by: Andrew G. Morgan Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- security/commoncap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/security/commoncap.c +++ b/security/commoncap.c @@ -244,10 +244,10 @@ static int get_file_caps(struct linux_bi struct vfs_cap_data vcaps; struct inode *inode; - if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID) { - bprm_clear_caps(bprm); + bprm_clear_caps(bprm); + + if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID) return 0; - } dentry = dget(bprm->file->f_dentry); inode = dentry->d_inode; -- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/