Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754183AbYKGXZd (ORCPT ); Fri, 7 Nov 2008 18:25:33 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753616AbYKGXW6 (ORCPT ); Fri, 7 Nov 2008 18:22:58 -0500 Received: from kroah.org ([198.145.64.141]:59217 "EHLO coco.kroah.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753572AbYKGXW6 (ORCPT ); Fri, 7 Nov 2008 18:22:58 -0500 Date: Fri, 7 Nov 2008 15:15:27 -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 07/23] file caps: always start with clear bprm->caps_* Message-ID: <20081107231527.GH1108@kroah.com> References: <20081107224818.593212310@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: <20081107231457.GA1108@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.26-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 @@ -247,10 +247,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/