Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp10150ybi; Wed, 29 May 2019 15:41:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwws7e+8XVmfej5uE3FZDZkN5m1yBQ++3zfYUpGIyZ2ypdiW6as/i+C29sTkqwkya6qwo6p X-Received: by 2002:a62:e803:: with SMTP id c3mr87886pfi.58.1559169682604; Wed, 29 May 2019 15:41:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559169682; cv=none; d=google.com; s=arc-20160816; b=ty5zXjfyWqSlhgejMDVPZ1J3+GvsLpIx38VsvXjreyabuxYQvvVQ2x/55YC5QrQbb9 jxeVy8YZBOT5kMx1Cd6xbNVUh/myVbLjQxI8Ege4xOHmf1KoBiaXm9y7TVnXEcyKv3Kq XAFlfr0fg+FuXLQlU/O0VPIJYP69y3ztxOL1AA4rz52dNbYAOxScdd6YZJ7nMHvCRLgv ot331g+enYbq7UriAap7OD+4IK3waOBi6lO2zgi4W1GPKtQfMi4PjH6gSAB7Jpf+k11+ 46zSOdvgc640vouz36eGWvHdHyRgotfu41Q0FwLFOqX1kDqdRsAKE4B/6g0R4rs0ZzDj YzQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=WTgrsrN2kv//1St2pvsmjLA5iqBOgmifLWx+zhYVKFA=; b=Bkp7O92YXQuEIxPgru5PJYJQzZoibcyAoVvHJ5mb57G5CXgQqc8XttWwGq3E7Ud5bh 8cPlPSctw1DLfNkliV1KK0hwrNXhEOyWaLt79wBDgg4R5JBtI2jAWDdVy4miU/FShJPF yqnHWOl/YEQM6EH6RF3OvWB5eaYkEhHT0g66sFw9XfPj7rPyXdCSh/sCVmcyNQfm815u weXLqsck9DM3546MLhI3SIKdh9RcOSbB3D4JX443KXmTN0FSqpdiLbMALu9kJIz35IN3 17sTseiuwYtLHT/eswqC1gLk0xJjqYNpRfwNQgtZnRQjs1eoQfrkPecuixwNmXrwrvxp BuQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=dQA6HRvG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14si1083409pfi.212.2019.05.29.15.41.06; Wed, 29 May 2019 15:41:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=dQA6HRvG; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbfE2WkD (ORCPT + 99 others); Wed, 29 May 2019 18:40:03 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:42154 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726395AbfE2WkC (ORCPT ); Wed, 29 May 2019 18:40:02 -0400 Received: by mail-lj1-f194.google.com with SMTP id y15so916342ljd.9 for ; Wed, 29 May 2019 15:40:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WTgrsrN2kv//1St2pvsmjLA5iqBOgmifLWx+zhYVKFA=; b=dQA6HRvG3+wzV5eXemCHoKBPfsIFBFsv2wTeLNycaFR8OykyginbjbUIT+4Y+EKPbn 66+our2twD97jFo/r1GvJljozn9a2WOhpNKWiSZxPrqe2x55z2gRDo/Hti9obvPDpCxy q0/82fxVtQ9NQbtPmOUGCIZVaSmj/O0i9tPpfbwg62BSmDBNpQ/ZDjb6CDHO0eIrG594 2Khitp6zhlMlPIaB+DbmKsslk5i4gt0fMhdFLXDZTeSG56f4xmZu/LzKkptugoepqPLd VsHmw7z6pxW6mEdkM++TXegVXY3pcTca5WN1sgP/IqMPAQ40mQ/JCxGRX5nkVko7dOCt eIbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WTgrsrN2kv//1St2pvsmjLA5iqBOgmifLWx+zhYVKFA=; b=F0pmZIa2m6GRHy6z2x6fEY3ftL4q6oRlz6TkmTv01z3EJFJgFaZAjL36yEimw8mU7p ZULMaRYGzHgxSd0M8CPT0E5K6eVFFGvgdTMjQ8LVNAkgu4SZHJg1fvZfHIdHt6sq1WET ES42yTRwUGiT71DEAS+h2mrfUzjQ1rtX25MIvCzTJLy38bIama/w50R0TQP9KJDYcTNC oEh7bVzx8P+qLB1JrzSGzzQMWR0f2Pt0PURT/aTFoL4yUDbViesN6AskG2xBj8X15n1d qpWTPt/idPxU6P8Shb0dyYjUajzZxHb+QArb/Vxa/xxRb51Ey0INOu9H+mZVJ1xOtcqt JBdA== X-Gm-Message-State: APjAAAWo1AxZPBZlGVbhRw47H3BULjl2HfnaIguOU3dqERel8iohMrNE Pf5fUHDU2rq1fukMvFSfBS+Y7zfCSoPjxh92beOu X-Received: by 2002:a2e:9a97:: with SMTP id p23mr173332lji.160.1559169600002; Wed, 29 May 2019 15:40:00 -0700 (PDT) MIME-Version: 1.0 References: <9edad39c40671fb53f28d76862304cc2647029c6.1554732921.git.rgb@redhat.com> <20190529145742.GA8959@cisco> <20190529153427.GB8959@cisco> <20190529222835.GD8959@cisco> In-Reply-To: <20190529222835.GD8959@cisco> From: Paul Moore Date: Wed, 29 May 2019 18:39:48 -0400 Message-ID: Subject: Re: [PATCH ghak90 V6 02/10] audit: add container id To: Tycho Andersen Cc: Richard Guy Briggs , containers@lists.linux-foundation.org, linux-api@vger.kernel.org, Linux-Audit Mailing List , linux-fsdevel@vger.kernel.org, LKML , netdev@vger.kernel.org, netfilter-devel@vger.kernel.org, sgrubb@redhat.com, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, Eric Paris , Serge Hallyn , ebiederm@xmission.com, nhorman@tuxdriver.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 29, 2019 at 6:28 PM Tycho Andersen wrote: > On Wed, May 29, 2019 at 12:03:58PM -0400, Paul Moore wrote: > > On Wed, May 29, 2019 at 11:34 AM Tycho Andersen wrote: > > > > > > On Wed, May 29, 2019 at 11:29:05AM -0400, Paul Moore wrote: > > > > On Wed, May 29, 2019 at 10:57 AM Tycho Andersen wrote: > > > > > > > > > > On Mon, Apr 08, 2019 at 11:39:09PM -0400, Richard Guy Briggs wrote: > > > > > > It is not permitted to unset the audit container identifier. > > > > > > A child inherits its parent's audit container identifier. > > > > > > > > > > ... > > > > > > > > > > > /** > > > > > > + * audit_set_contid - set current task's audit contid > > > > > > + * @contid: contid value > > > > > > + * > > > > > > + * Returns 0 on success, -EPERM on permission failure. > > > > > > + * > > > > > > + * Called (set) from fs/proc/base.c::proc_contid_write(). > > > > > > + */ > > > > > > +int audit_set_contid(struct task_struct *task, u64 contid) > > > > > > +{ > > > > > > + u64 oldcontid; > > > > > > + int rc = 0; > > > > > > + struct audit_buffer *ab; > > > > > > + uid_t uid; > > > > > > + struct tty_struct *tty; > > > > > > + char comm[sizeof(current->comm)]; > > > > > > + > > > > > > + task_lock(task); > > > > > > + /* Can't set if audit disabled */ > > > > > > + if (!task->audit) { > > > > > > + task_unlock(task); > > > > > > + return -ENOPROTOOPT; > > > > > > + } > > > > > > + oldcontid = audit_get_contid(task); > > > > > > + read_lock(&tasklist_lock); > > > > > > + /* Don't allow the audit containerid to be unset */ > > > > > > + if (!audit_contid_valid(contid)) > > > > > > + rc = -EINVAL; > > > > > > + /* if we don't have caps, reject */ > > > > > > + else if (!capable(CAP_AUDIT_CONTROL)) > > > > > > + rc = -EPERM; > > > > > > + /* if task has children or is not single-threaded, deny */ > > > > > > + else if (!list_empty(&task->children)) > > > > > > + rc = -EBUSY; > > > > > > + else if (!(thread_group_leader(task) && thread_group_empty(task))) > > > > > > + rc = -EALREADY; > > > > > > + read_unlock(&tasklist_lock); > > > > > > + if (!rc) > > > > > > + task->audit->contid = contid; > > > > > > + task_unlock(task); > > > > > > + > > > > > > + if (!audit_enabled) > > > > > > + return rc; > > > > > > > > > > ...but it is allowed to change it (assuming > > > > > capable(CAP_AUDIT_CONTROL), of course)? Seems like this might be more > > > > > immediately useful since we still live in the world of majority > > > > > privileged containers if we didn't allow changing it, in addition to > > > > > un-setting it. > > > > > > > > The idea is that only container orchestrators should be able to > > > > set/modify the audit container ID, and since setting the audit > > > > container ID can have a significant effect on the records captured > > > > (and their routing to multiple daemons when we get there) modifying > > > > the audit container ID is akin to modifying the audit configuration > > > > which is why it is gated by CAP_AUDIT_CONTROL. The current thinking > > > > is that you would only change the audit container ID from one > > > > set/inherited value to another if you were nesting containers, in > > > > which case the nested container orchestrator would need to be granted > > > > CAP_AUDIT_CONTROL (which everyone to date seems to agree is a workable > > > > compromise). > > > > > > But then don't you want some kind of ns_capable() instead (probably > > > not the obvious one, though...)? With capable(), you can't really nest > > > using the audit-id and user namespaces together. > > > > You want capable() and not ns_capable() because you want to ensure > > that the orchestrator has the rights in the init_ns as changes to the > > audit container ID could have an auditing impact that spans the entire > > system. > > Ok but, > > > > > The current thinking > > > > is that you would only change the audit container ID from one > > > > set/inherited value to another if you were nesting containers, in > > > > which case the nested container orchestrator would need to be granted > > > > CAP_AUDIT_CONTROL (which everyone to date seems to agree is a workable > > > > compromise). > > won't work in user namespaced containers, because they will never be > capable(CAP_AUDIT_CONTROL); so I don't think this will work for > nesting as is. But maybe nobody cares :) That's fun :) To be honest, I've never been a big fan of supporting nested containers from an audit perspective, so I'm not really too upset about this. The k8s/cri-o folks seem okay with this, or at least I haven't heard any objections; lxc folks, what do you have to say? -- paul moore www.paul-moore.com