Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6446369ybi; Wed, 29 May 2019 07:59:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzykNdApHCuFCpYp3SNgNNH5wmr1aHkU+4GiPDm6cQMQFKUJGLhUPHnNpomMSHaA954DXIw X-Received: by 2002:a17:902:ab97:: with SMTP id f23mr88163256plr.237.1559141961204; Wed, 29 May 2019 07:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559141961; cv=none; d=google.com; s=arc-20160816; b=BIchUeFbEYZ/zlmJlclrEFadjG6Zrkkm3Z6hORQPE85je70MJHXoe7/wtDNRYPJE9v 6U362eq68aopmV1ptVroQhC9pBsaCn6FYTlk/elMgvURAThqjKHE2Gq8CXfuHKnICE3I 4EVYutVo9w5G1iSo+kZ8soMD9Rr9G4jAwkXYVnix00asc13dlq5r6MqoDwps+6Dq7ql6 l3Q5kWAIidK8l+uMzZdehFNVZp3DS1Y4hIi9uPfQv2BFDQpku5TK97FjZV+jLQqPa6Yl SyLhBNv1FV8AE7QfstDyQdPx4EeFlmMy0aelS3xV8CLqf+btvQ7OT6zMDz6A+MRt3ald GEFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sIAmsJEpBYAFITCiVn5ontRF8mPnuiYWYs/RXhqJVik=; b=meupIdxQ698rc1pQOcO9vlnS3w/3vT3jXGJY8cYXvUn6Z18oMspUOvdoO+ZSn0SjZd nb8+qk4xESWj/J/2dP8frOMF1eOA5eCprOwG84fnBAYvAlZvu0R1nA7J+LE09o71iaCd Z0r3HkCI/F7yr6JeONI/DG6jJWe5bzKw4m/0cacBAWOczJdhSv1KKLTE15gVmRRmW6rV JknsY49PNm9SBr3kW536feAvb9AC5xP1QXOO+OtJxdtVdqpGsNGDDEemt/28sUXuQRyW aareS1S5ONX8WFt0UKpnC784FQPquSWlnLCTKvhUR5sDQ6pswKDjBHDWjvEuxTKxhhxT s5BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b="WX7P/J1W"; 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 c8si25057513pfi.188.2019.05.29.07.59.05; Wed, 29 May 2019 07:59:21 -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=@tycho-ws.20150623.gappssmtp.com header.s=20150623 header.b="WX7P/J1W"; 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 S1726678AbfE2O5s (ORCPT + 99 others); Wed, 29 May 2019 10:57:48 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42349 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726396AbfE2O5r (ORCPT ); Wed, 29 May 2019 10:57:47 -0400 Received: by mail-pg1-f195.google.com with SMTP id 33so49444pgv.9 for ; Wed, 29 May 2019 07:57:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tycho-ws.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sIAmsJEpBYAFITCiVn5ontRF8mPnuiYWYs/RXhqJVik=; b=WX7P/J1WgZ/D9lrZgOu1anQ6YIHb47wFUL+vzOPy5wp7tMGaB3GMXODl41EgHc8fmy O7CyTYBnpED9Ui08UL7+gG+G4ETtS6EPVbUOEwzGM3Gv+sMqOt9+eBigGG2ZScn8Gn+B mafYiq2WG7VzWLDTbnjHuyxYslOU/8LCyAkITg+lJDaaG8rsFUNzAf06z5HPQAwDuMnZ DDJCih2aBYGHvXSVQn3uSHbkEXIZIcuTm6aXFc7EHyMOA7oZW2kJ3aA+EKTvV+f/8kzR kd5R5mNQMOwiYz89vs7++vyO0bxo90i9bXogfTrnumYixYFV7p9mNBFBfwtXMp1IzGFS rm3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sIAmsJEpBYAFITCiVn5ontRF8mPnuiYWYs/RXhqJVik=; b=GijYK2xahCwCmE531MpIGekYCtM6T238VrhUVGy/DIwSbUWmOGnV3c/59B4gfeqwCx Oxgze7KbVnNb14xVP7dce1dI2FELTr9NN+0/aQGnrIQ4E2JKamvj96sg2HINjX2GBsPI Xzmn+fyXVR3XP6q6LfOwpdV8BulC8T2GuVgaHLDHr2BTUKa9zypZzglTw/FCxcieDSpU 3bGqQKJ58izK+BHoR4GMbzOUnVLwph3+DWJYIPOMvG4sw6KsmSuz6U+QtH2WPR853kkc P+zM/vUxIE9REM1l9a/6iIO3/wGWBpizdnFv3KWRPwtkd6gXSMF4cXX1463YoJo+CxjD bLkQ== X-Gm-Message-State: APjAAAUlnkLW7KVRHFkiz9Yrw1E9YG/BjGhGWcXA5ExGIdfpCNXFj1ht U0vI4rA9vhVW50fnBzPFrhcG0A== X-Received: by 2002:a63:ff0c:: with SMTP id k12mr32442911pgi.32.1559141866858; Wed, 29 May 2019 07:57:46 -0700 (PDT) Received: from cisco ([2601:280:b:edbb:840:fa90:7243:7032]) by smtp.gmail.com with ESMTPSA id t11sm15682423pgp.1.2019.05.29.07.57.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 May 2019 07:57:46 -0700 (PDT) Date: Wed, 29 May 2019 08:57:42 -0600 From: Tycho Andersen To: Richard Guy Briggs Cc: 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, Paul Moore , sgrubb@redhat.com, omosnace@redhat.com, dhowells@redhat.com, simo@redhat.com, eparis@parisplace.org, serge@hallyn.com, ebiederm@xmission.com, nhorman@tuxdriver.com Subject: Re: [PATCH ghak90 V6 02/10] audit: add container id Message-ID: <20190529145742.GA8959@cisco> References: <9edad39c40671fb53f28d76862304cc2647029c6.1554732921.git.rgb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9edad39c40671fb53f28d76862304cc2647029c6.1554732921.git.rgb@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Tycho