Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2004897ybk; Sun, 17 May 2020 07:20:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVUg9W336108wRr1aFvvaOvHE2Eq27/u35ZMTB0821aoFt0H21QgbGRwGghzmQbdTLbR2W X-Received: by 2002:a05:6402:17a3:: with SMTP id j3mr10513339edy.137.1589725228037; Sun, 17 May 2020 07:20:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589725228; cv=none; d=google.com; s=arc-20160816; b=LzcwmT8nMLoR4Tv0DYXPnj8K+EOYDcunU3JfHY3BO4UJlznHxz3sMBDjKGKxn6lD8L CNb8kfmlLFE0JiqQdspAmoKhgD9vrF1Jc0yiU1sVZuk3go4I5LXHUl5nGTNlSV5O2etd kTpSKwGTpU8ECw7SU5wjPKovafG3L2oa0cmOvOeDXg3rfWZHxA8Zw8lwwGxX30ARcQhX DfZvTWCRWVYmGlVW7H/KXVzU4Z8q1ZCaQGlGGhb9uCBR6PgXV3Pd8f0OvY+uN3aLSgXu IN7C6dqZEA0H4mfzzMy4gm+Dt9qQJlBlSG/7gFyO/LIVtkGjLvONd+7Z9x93tvrB+neA DHCA== 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=ZSCD2rskbMKGy3GhvSaftPT2Y5k+GJ/7kryyIprAvdw=; b=QBg2gC6Vowf5TVuEDtxAdtXIpuo8wRer/IMQVjC55fFl5qoc8kKbOzAGAzUAGcBfWo T2i85NixKZAE+SQwqGcfv9ZpBhZke+PR5AqfCzS/592h6bCqkklWaTrONRyLHS7/HZfl DeVKTLh4lKE9VFKSrVWBEmWdkA7BmJ8/JEXFOYB6ftYbVu4E8k/xTbPXS7RsswycolVq 6x4k/W1BDzkyAY8nn4+cUm3jcJO0ZWr54Duh21Ki5OKS7m9BmUbI+hfxHFCNMTDjXmYC ItLr4bWj12bQWmOCFBFMKwppkN9BItu8jYu8TsZaq91aCgsO1ZZaISnqiQUqgVXBlF0x m0NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AQHNj2p1; 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 mb2si2439909ejb.270.2020.05.17.07.20.03; Sun, 17 May 2020 07:20:28 -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=AQHNj2p1; 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 S1727970AbgEQOPe (ORCPT + 99 others); Sun, 17 May 2020 10:15:34 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51712 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727893AbgEQOPe (ORCPT ); Sun, 17 May 2020 10:15:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1589724932; 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: in-reply-to:in-reply-to:references:references; bh=ZSCD2rskbMKGy3GhvSaftPT2Y5k+GJ/7kryyIprAvdw=; b=AQHNj2p1or6dyAi+aujwENogmex3xcdZwV0dmXUPm5UoccCKJ3jlg6ytMQHin4w+yk7IXQ bQCMoujz7VCdBEtyH2pCTCxeMfPlYZnNldyefKsLxbhG3UH1zbuNKJj1sHDxQU2EZU8PMY DuhinuHOtsCM0pGtYcIPHtgMK80bJ28= 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-377-kdyH184UP7q8iWcgAZwJLQ-1; Sun, 17 May 2020 10:15:27 -0400 X-MC-Unique: kdyH184UP7q8iWcgAZwJLQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8CEF01005510; Sun, 17 May 2020 14:15:25 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.10.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F316D5D9D7; Sun, 17 May 2020 14:15:17 +0000 (UTC) Date: Sun, 17 May 2020 10:15:15 -0400 From: Richard Guy Briggs To: Paul Moore Cc: fw@strlen.de, LKML , Linux-Audit Mailing List , netfilter-devel@vger.kernel.org, ebiederm@xmission.com, twoerner@redhat.com, Eric Paris , tgraf@infradead.org Subject: Re: [PATCH ghak25 v4 3/3] audit: add subj creds to NETFILTER_CFG record to cover async unregister Message-ID: <20200517141515.qqx3jx5ulb2546tx@madcap2.tricolour.ca> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-04-28 18:25, Paul Moore wrote: > On Wed, Apr 22, 2020 at 5:40 PM Richard Guy Briggs wrote: > > Some table unregister actions seem to be initiated by the kernel to > > garbage collect unused tables that are not initiated by any userspace > > actions. It was found to be necessary to add the subject credentials to > > cover this case to reveal the source of these actions. A sample record: > > > > type=NETFILTER_CFG msg=audit(2020-03-11 21:25:21.491:269) : table=nat family=bridge entries=0 op=unregister pid=153 uid=root auid=unset tty=(none) ses=unset subj=system_u:system_r:kernel_t:s0 comm=kworker/u4:2 exe=(null) > > [I'm going to comment up here instead of in the code because it is a > bit easier for everyone to see what the actual impact might be on the > records.] > > Steve wants subject info in this case, okay, but let's try to trim out > some of the fields which simply don't make sense in this record; I'm > thinking of fields that are unset/empty in the kernel case and are > duplicates of other records in the userspace/syscall case. I think > that means we can drop "tty", "ses", "comm", and "exe" ... yes? > > While "auid" is a potential target for removal based on the > dup-or-unset criteria, I think it falls under Steve's request for > subject info here, even if it is garbage in this case. Can you explain why auid falls under this criteria but ses does not if both are unset? If auid is unset then we know ses is unset? If subj contains *:kernel_t:* then uid can also be dropped even though it is set, no? I figure if we are going to start dropping fields, might as well drop enough to make it worth the effort, even though this is a rare event. As for searchability, I have solved that easily in the parser. > > Signed-off-by: Richard Guy Briggs > > --- > > kernel/auditsc.c | 18 ++++++++++++++++++ > > 1 file changed, 18 insertions(+) > > > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > index d281c18d1771..d7a45b181be0 100644 > > --- a/kernel/auditsc.c > > +++ b/kernel/auditsc.c > > @@ -2557,12 +2557,30 @@ void __audit_log_nfcfg(const char *name, u8 af, unsigned int nentries, > > enum audit_nfcfgop op) > > { > > struct audit_buffer *ab; > > + const struct cred *cred; > > + struct tty_struct *tty; > > + char comm[sizeof(current->comm)]; > > > > ab = audit_log_start(audit_context(), GFP_KERNEL, AUDIT_NETFILTER_CFG); > > if (!ab) > > return; > > audit_log_format(ab, "table=%s family=%u entries=%u op=%s", > > name, af, nentries, audit_nfcfgs[op].s); > > + > > + cred = current_cred(); > > + tty = audit_get_tty(); > > + audit_log_format(ab, " pid=%u uid=%u auid=%u tty=%s ses=%u", > > + task_pid_nr(current), > > + from_kuid(&init_user_ns, cred->uid), > > + from_kuid(&init_user_ns, audit_get_loginuid(current)), > > + tty ? tty_name(tty) : "(none)", > > + audit_get_sessionid(current)); > > + audit_put_tty(tty); > > + audit_log_task_context(ab); /* subj= */ > > + audit_log_format(ab, " comm="); > > + audit_log_untrustedstring(ab, get_task_comm(comm, current)); > > + audit_log_d_path_exe(ab, current->mm); /* exe= */ > > + > > audit_log_end(ab); > > } > > EXPORT_SYMBOL_GPL(__audit_log_nfcfg); > > paul moore - 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