Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3825442pxj; Tue, 11 May 2021 12:44:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygA7BWg8iRQaDYyr6JLAEZWnWvyviTkXMqPkI/8aFLRp0wDleMo+6sJd7r24LLSKu1SpzQ X-Received: by 2002:a17:907:9d3:: with SMTP id bx19mr171240ejc.63.1620762255770; Tue, 11 May 2021 12:44:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620762255; cv=none; d=google.com; s=arc-20160816; b=xG/zL4pA56O1GCptikThLD9FG/6xETD7cj+BfJh4vP0CPcPbVdLHEUD2olAq6BFLxL wFrmUlhmpCXY7IufpWKCvijtW4RVEx9v5GacmJQacsHVpOIUmMLxSyhogeu1Lw2LIzlb Zidpj8as4Kxt5ZXOkvrt5DkCsv0DUAu3j3uA8/OgjLjp81r23ceAJqIheITTCBUhk8ec cskdZOkP4M7xu/3PpDpKYPmjJfI+vDTIHZRF6E+fOvH24mUxvBw4bkvGIF72m0gVubW4 WfwoSxMjdqknxpV9lTFcrCOfHObmSgkxpclu/NAqq9wzlz7sGKX0b+dai7wjpDtaEN28 1/Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=rj6L9PURkNx4/ivnoPgM1A+pOZdnCZXr7aAOI6YcF60=; b=0If6jfECP0nzLC4e5uDtZ3UYkAy12V+wthuXcKacYHF1oQxaXBsSpcSNZGZlqXnDwc LtsqVfA4hShVCBdSglR1DKs5yWEi0FF76RPPR4+durvWq6P2PAaaJxODYxpgIf3MusmD CZSrc+yEoE+pyf7zRjfisQ0IZrDwFKGyCgDlqPKIOL2e3v5u3H7bRmvlg8n8Te98wgnI XR/gARZQUEjE0iZ+GnoxE9KfwLIQk3xCAy/GEctjaXNg7gwoKtIW7tP/sMBgKcEi13yV KwNfYVA62qSt4PCDibYPYfQcl8JxqM0tYbp+o3cpFWNUwxI/V4Pa8Hn0zAeGAAhbCyBY iPUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Y8IfC/px"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w13si1086668edx.449.2021.05.11.12.43.51; Tue, 11 May 2021 12:44:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Y8IfC/px"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232052AbhEKTly (ORCPT + 99 others); Tue, 11 May 2021 15:41:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21067 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231944AbhEKTlx (ORCPT ); Tue, 11 May 2021 15:41:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620762046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rj6L9PURkNx4/ivnoPgM1A+pOZdnCZXr7aAOI6YcF60=; b=Y8IfC/pxbvbLdHUNHo1zQ8qjKX5HNi99jDSQset5AQWty5fLukkjciSRCTo3R8y2JUBpkn G/ECXdozC/uLw56pG+IIvWtyZi8wLBJ/7eQSHctZnAhfGwjds45wSpxAS9rIB/bsd2V1P8 mQkxlpO9HCbITMqLd3psj8GWq/X6W3Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-UKPH0FMIM-CilANLQZdxuQ-1; Tue, 11 May 2021 15:40:40 -0400 X-MC-Unique: UKPH0FMIM-CilANLQZdxuQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9416B1854E25; Tue, 11 May 2021 19:40:39 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.3.128.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 881A71037F34; Tue, 11 May 2021 19:40:31 +0000 (UTC) Date: Tue, 11 May 2021 15:40:28 -0400 From: Richard Guy Briggs To: Paul Moore Cc: Michael =?iso-8859-1?Q?Wei=DF?= , Eric Paris , linux-audit@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] audit: allow logging of user events in non-initial namespace. Message-ID: <20210511194028.GQ3141668@madcap2.tricolour.ca> References: <20210509183319.20298-1-michael.weiss@aisec.fraunhofer.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-05-10 18:48, Paul Moore wrote: > On Sun, May 9, 2021 at 2:33 PM Michael Wei? > wrote: > > > > Audit subsystem was disabled in total for user namespaces other than > > the initial namespace. > > > > If audit is enabled by kernel command line or audtid in initial namespace, > > it is now possible to allow at least logging of userspace applications > > inside of non-initial namespaces if CAP_AUDIT_WRITE in the corresponding > > namespace is held. > > > > This allows logging of, e.g., PAM or opensshd inside user namespaced > > system containers. > > > > Signed-off-by: Michael Wei? > > --- > > kernel/audit.c | 10 ++++++++-- > > 1 file changed, 8 insertions(+), 2 deletions(-) > > I think this needs to wait on the audit container ID patchset to land. That will interact with this, for sure and others related. Given that there are non-init namespaces involved that may not be part of containers, I would prefer to wait until namespaces are also optionally documentable in audit events before permitting this change. A patchset exists, but it has been deferred until the audit container identifier patchset is settled. (See https://github.com/linux-audit/audit-kernel/issues/32 ) > > diff --git a/kernel/audit.c b/kernel/audit.c > > index 121d37e700a6..b5cc0669c3d7 100644 > > --- a/kernel/audit.c > > +++ b/kernel/audit.c > > @@ -1012,7 +1012,13 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) > > * userspace will reject all logins. This should be removed when we > > * support non init namespaces!! > > */ > > - if (current_user_ns() != &init_user_ns) > > + /* > > + * If audit is enabled by kernel command line or audtid in the initial > > + * namespace allow at least logging of userspace applications inside of > > + * non-initial namespaces according to CAP_AUDIT_WRITE is held in the > > + * corresponding namespace. > > + */ > > + if ((current_user_ns() != &init_user_ns) && !audit_enabled) > > return -ECONNREFUSED; > > > > switch (msg_type) { > > @@ -1043,7 +1049,7 @@ static int audit_netlink_ok(struct sk_buff *skb, u16 msg_type) > > case AUDIT_USER: > > case AUDIT_FIRST_USER_MSG ... AUDIT_LAST_USER_MSG: > > case AUDIT_FIRST_USER_MSG2 ... AUDIT_LAST_USER_MSG2: > > - if (!netlink_capable(skb, CAP_AUDIT_WRITE)) > > + if (!netlink_ns_capable(skb, current_user_ns(), CAP_AUDIT_WRITE)) > > err = -EPERM; > > break; > > default: /* bad msg */ > > -- > > 2.20.1 > > -- > paul moore > www.paul-moore.com > - RGB -- Richard Guy Briggs Sr. S/W Engineer, Kernel Security, Base Operating Systems Remote, Ottawa, Red Hat Canada IRC: rgb, SunRaycer Voice: +1.647.777.2635, Internal: (81) 32635