Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966490AbbBDWdB (ORCPT ); Wed, 4 Feb 2015 17:33:01 -0500 Received: from mail-la0-f43.google.com ([209.85.215.43]:44899 "EHLO mail-la0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965339AbbBDWc6 (ORCPT ); Wed, 4 Feb 2015 17:32:58 -0500 MIME-Version: 1.0 In-Reply-To: <20150204220211.GB21613@mail.hallyn.com> References: <20150204211617.GA20787@mail.hallyn.com> <20150204212743.GA21475@mail.hallyn.com> <20150204215158.GA21613@mail.hallyn.com> <20150204220211.GB21613@mail.hallyn.com> From: Andy Lutomirski Date: Wed, 4 Feb 2015 14:32:36 -0800 Message-ID: Subject: Re: [RFC] Implement ambient capability set. To: "Serge E. Hallyn" Cc: Christoph Lameter , "Andrew G. Morgan" , Serge Hallyn , Serge Hallyn , Jonathan Corbet , Aaron Jones , "Ted Ts'o" , LSM List , lkml , Andrew Morton Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3488 Lines: 81 On Wed, Feb 4, 2015 at 2:02 PM, Serge E. Hallyn wrote: > Quoting Serge E. Hallyn (serge@hallyn.com): >> Quoting Andy Lutomirski (luto@amacapital.net): >> > On Wed, Feb 4, 2015 at 1:27 PM, Serge E. Hallyn wrote: >> > > Quoting Andy Lutomirski (luto@amacapital.net): >> > >> On Wed, Feb 4, 2015 at 1:16 PM, Serge E. Hallyn wrote: >> > >> > Quoting Andy Lutomirski (luto@amacapital.net): >> > >> >> On Wed, Feb 4, 2015 at 10:49 AM, Christoph Lameter wrote: >> > >> >> > + >> > >> >> > + if (!cap_valid(arg2)) >> > >> >> > + return -EINVAL; >> > >> >> > + >> > >> >> > + new =prepare_creds(); >> > >> >> > + if (arg3 == 0) >> > >> >> > + cap_lower(new->cap_ambient, arg2); >> > >> >> > + else >> > >> >> > + cap_raise(new->cap_ambient, arg2); >> > >> >> > + return commit_creds(new); >> > >> >> > + >> > >> >> >> > >> >> This let you add capabilities you don't even have to cap_ambient. I'm >> > >> >> fine with that as long as the cap evolution rule changes, as above. >> > >> > >> > >> > How about if instead we do restrict it to what's in pP? I don't >> > >> > want CAP_SETPCAP to become a cheap way to get all caps back. With >> > >> > or without NNP. >> > >> >> > >> We'd also have to modify everything that can change pP to change pA as >> > >> well if we went this route. I'd be okay with that, but it would make >> > >> the patch much larger, and I'm not entirely sure I see the benefit. >> > >> It would keep the number of possible states smaller, which could be >> > >> nice. >> > > >> > > Do you mean if we didn't require NNP? I'm suggesting that even if >> > > we require NNP we should restrict any new bits added to pA to be >> > > in pP at the prctl call. Then whether or not to drop them from >> > > pA when they are dropped from pP, I'm not yet certain. >> > >> > I mean regardless of whether we require NNP. >> > >> > I think that, unless we change the evolution rule, we would need to >> > drop from pA when bits are dropped from pP to preserve the idea that >> > dropping bits from pP drops them for good (as long as ruid != 0 or >> > some securebit is set). >> >> Ok, so iiuc the rules would be: >> >> 1. must set nnp and have ns_capable(CAP_SETPCAP) to >> call prctl(PR_SET_AMBIENT_WHATEVER) >> >> 2. adding bits to pA requires they be in pP at prctl time >> >> 3. dropping bits from pP drops them also from pA I'm still unconvinced that 2 and 3 is better than using pP & pA in execve, but I could go either way on that. >> >> 4. at exec, fP |= pA; pA' = pA > > Actually I'm tempted to say that if fP is not empty, then we stick with current > rules for fP/pP and clear out pA. If fP is empty, then fP = pA > > Then, if fP is not empty on the file, we either drop nnp at exec (or > don't use nnp at all), or we refuse exec if fP > pA. We can't drop nnp at exec. > > We definately do not want to run a file which has capability X > in fP, when X is not in pA. Confused. This will break everything, including Christoph's use case. The status quo for running ping from bash has pA == 0 and fP != 0. --Andy -- 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/