Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752777AbZLaQtL (ORCPT ); Thu, 31 Dec 2009 11:49:11 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752675AbZLaQtK (ORCPT ); Thu, 31 Dec 2009 11:49:10 -0500 Received: from out01.mta.xmission.com ([166.70.13.231]:50101 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752625AbZLaQtJ (ORCPT ); Thu, 31 Dec 2009 11:49:09 -0500 To: "Serge E. Hallyn" Cc: "Andrew G. Morgan" , Bryan Donlan , Alan Cox , Benny Amorsen , Michael Stone , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-security-module@vger.kernel.org, Andi Kleen , David Lang , Oliver Hartkopp , Herbert Xu , Valdis Kletnieks , Evgeniy Polyakov , "C. Scott Ananian" , James Morris , Bernie Innocenti , Mark Seaborn , Randy Dunlap , =?utf-8?Q?Am=C3=A9rico?= Wang , Tetsuo Handa , Samir Bellabes , Casey Schaufler , Pavel Machek , Al Viro Subject: Re: [RFC][PATCH v3] Unprivileged: Disable raising of privileges References: <3e8340490912291954v5a837a26p64bd776102d281d7@mail.gmail.com> <3e8340490912292057g3e87eaabn115f85b78af2b08c@mail.gmail.com> <551280e50912300652r1007dee0j8de750bf33af9b3c@mail.gmail.com> <20091230183513.GC14493@us.ibm.com> <20091230201712.GA23999@us.ibm.com> <20091231152523.GA12969@us.ibm.com> From: ebiederm@xmission.com (Eric W. Biederman) Date: Thu, 31 Dec 2009 08:48:45 -0800 In-Reply-To: <20091231152523.GA12969@us.ibm.com> (Serge E. Hallyn's message of "Thu\, 31 Dec 2009 09\:25\:23 -0600") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-XM-SPF: eid=;;;mid=;;;hst=in02.mta.xmission.com;;;ip=76.21.114.89;;;frm=ebiederm@xmission.com;;;spf=neutral X-SA-Exim-Connect-IP: 76.21.114.89 X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Scanned: No (on in02.mta.xmission.com); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1487 Lines: 42 "Serge E. Hallyn" writes: >> diff --git a/security/commoncap.c b/security/commoncap.c >> index f800fdb..34500e3 100644 >> --- a/security/commoncap.c >> +++ b/security/commoncap.c >> @@ -389,7 +389,7 @@ static int get_file_caps(struct linux_binprm *bprm, bool *effective) >> if (!file_caps_enabled) >> return 0; >> >> - if (bprm->file->f_vfsmnt->mnt_flags & MNT_NOSUID) >> + if (bprm->nosuid) >> return 0; > > I'm sorry, this may actually not be sufficient. > > Could you try the following test on a kernel with this patch? : > > 1. become root > 2. do prctl(PR_SET_NOSUID); > 3. run bash, and examine your capabilities in /proc/self/status > > I think the code in security/commoncap.c:457-458 will re-raise your > capabilities. Right. That is a legitimate issue. I almost guard against it with my test against with my start condition test of cap_isclear(cred->cap_permitted). Which causes this to fail for root in most situations. I will add a test for the securebits, and deny this to root unless the securebits are such that root cannot gain privilege. Thanks for catching this. I figured I might need a uid == 0 exclusion. Where the test was split when I wrote it I wasn't certain where to put it. Eric -- 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/