From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-22.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DE05C433C1 for ; Thu, 25 Mar 2021 03:15:55 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CFDDB61A18 for ; Thu, 25 Mar 2021 03:15:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFDDB61A18 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=tempfail smtp.mailfrom=linux-audit-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1616642153; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=fwUtu1/2Vtq264gd63JKPtLs9fTljeFOo/2i6cEsmCY=; b=FwPAauXtUgUgpLxcWeQ6OPA9U8wmI7cprssWIbFEJQGczmCf0C7x13DmHzAWaD/V4MFRuY Lge3lvq/OBDWDTBEccgYYNPR9Qx7wFB4jztvySXPBKuTrED2k2VA8g5UMfTvuKirjn3NcJ Rp09RAuSx5mUmGTB5PtYIdkvpTNWQzo= 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-50-LM0hwQ7CPCedXe-jP0ZTSw-1; Wed, 24 Mar 2021 23:15:51 -0400 X-MC-Unique: LM0hwQ7CPCedXe-jP0ZTSw-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 89152107ACCD; Thu, 25 Mar 2021 03:15:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ACCB310023B0; Thu, 25 Mar 2021 03:15:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E18944BB7C; Thu, 25 Mar 2021 03:15:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 12P3Fifn005578 for ; Wed, 24 Mar 2021 23:15:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1755569FD1; Thu, 25 Mar 2021 03:15:44 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.10.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 172DA19C93; Thu, 25 Mar 2021 03:15:34 +0000 (UTC) Date: Wed, 24 Mar 2021 23:15:32 -0400 From: Richard Guy Briggs To: Paul Moore Subject: Re: [PATCH v3] audit: log nftables configuration change events once per table Message-ID: <20210325031532.GU3141668@madcap2.tricolour.ca> References: <3d15fa1f0c54335f9258d90ea0d11050e780ba70.1616529248.git.rgb@redhat.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: linux-audit@redhat.com Cc: Jones Desougi , Phil Sutter , Florian Westphal , LKML , Linux-Audit Mailing List , netfilter-devel@vger.kernel.org, twoerner@redhat.com, Eric Paris , tgraf@infradead.org, dan.carpenter@oracle.com X-BeenThere: linux-audit@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Linux Audit Discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-audit-bounces@redhat.com Errors-To: linux-audit-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=linux-audit-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 2021-03-24 12:32, Paul Moore wrote: > On Tue, Mar 23, 2021 at 4:05 PM Richard Guy Briggs wrote: > > > > Reduce logging of nftables events to a level similar to iptables. > > Restore the table field to list the table, adding the generation. > > > > Indicate the op as the most significant operation in the event. > > > > A couple of sample events: > > > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.801:143) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > > type=SYSCALL msg=audit(2021-03-18 09:30:49.801:143) : arch=x86_64 syscall=sendmsg success=yes exit=172 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=roo > > t sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv6 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=ipv4 entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.801:143) : table=firewalld:2 family=inet entries=1 op=nft_register_table pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > > > type=PROCTITLE msg=audit(2021-03-18 09:30:49.839:144) : proctitle=/usr/bin/python3 -s /usr/sbin/firewalld --nofork --nopid > > type=SYSCALL msg=audit(2021-03-18 09:30:49.839:144) : arch=x86_64 syscall=sendmsg success=yes exit=22792 a0=0x6 a1=0x7ffdcfcbe650 a2=0x0 a3=0x7ffdcfcbd52c items=0 ppid=1 pid=367 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=r > > oot sgid=root fsgid=root tty=(none) ses=unset comm=firewalld exe=/usr/bin/python3.9 subj=system_u:system_r:firewalld_t:s0 key=(null) > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv6 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=ipv4 entries=30 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > type=NETFILTER_CFG msg=audit(2021-03-18 09:30:49.839:144) : table=firewalld:3 family=inet entries=165 op=nft_register_chain pid=367 subj=system_u:system_r:firewalld_t:s0 comm=firewalld > > > > The issue was originally documented in > > https://github.com/linux-audit/audit-kernel/issues/124 > > > > Signed-off-by: Richard Guy Briggs > > --- > > Changelog: > > v3: > > - fix function braces, reduce parameter scope > > - pre-allocate nft_audit_data per table in step 1, bail on ENOMEM > > > > v2: > > - convert NFT ops to array indicies in nft2audit_op[] > > - use linux lists > > - use functions for each of collection and logging of audit data > > --- > > include/linux/audit.h | 28 ++++++ > > net/netfilter/nf_tables_api.c | 160 ++++++++++++++++------------------ > > 2 files changed, 105 insertions(+), 83 deletions(-) > > ... > > > diff --git a/include/linux/audit.h b/include/linux/audit.h > > index 82b7c1116a85..5fafcf4c13de 100644 > > --- a/include/linux/audit.h > > +++ b/include/linux/audit.h > > @@ -118,6 +118,34 @@ enum audit_nfcfgop { > > AUDIT_NFT_OP_INVALID, > > }; > > > > +static const u8 nft2audit_op[NFT_MSG_MAX] = { // enum nf_tables_msg_types > > + [NFT_MSG_NEWTABLE] = AUDIT_NFT_OP_TABLE_REGISTER, > > + [NFT_MSG_GETTABLE] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_DELTABLE] = AUDIT_NFT_OP_TABLE_UNREGISTER, > > + [NFT_MSG_NEWCHAIN] = AUDIT_NFT_OP_CHAIN_REGISTER, > > + [NFT_MSG_GETCHAIN] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_DELCHAIN] = AUDIT_NFT_OP_CHAIN_UNREGISTER, > > + [NFT_MSG_NEWRULE] = AUDIT_NFT_OP_RULE_REGISTER, > > + [NFT_MSG_GETRULE] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_DELRULE] = AUDIT_NFT_OP_RULE_UNREGISTER, > > + [NFT_MSG_NEWSET] = AUDIT_NFT_OP_SET_REGISTER, > > + [NFT_MSG_GETSET] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_DELSET] = AUDIT_NFT_OP_SET_UNREGISTER, > > + [NFT_MSG_NEWSETELEM] = AUDIT_NFT_OP_SETELEM_REGISTER, > > + [NFT_MSG_GETSETELEM] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_DELSETELEM] = AUDIT_NFT_OP_SETELEM_UNREGISTER, > > + [NFT_MSG_NEWGEN] = AUDIT_NFT_OP_GEN_REGISTER, > > + [NFT_MSG_GETGEN] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_TRACE] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_NEWOBJ] = AUDIT_NFT_OP_OBJ_REGISTER, > > + [NFT_MSG_GETOBJ] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_DELOBJ] = AUDIT_NFT_OP_OBJ_UNREGISTER, > > + [NFT_MSG_GETOBJ_RESET] = AUDIT_NFT_OP_OBJ_RESET, > > + [NFT_MSG_NEWFLOWTABLE] = AUDIT_NFT_OP_FLOWTABLE_REGISTER, > > + [NFT_MSG_GETFLOWTABLE] = AUDIT_NFT_OP_INVALID, > > + [NFT_MSG_DELFLOWTABLE] = AUDIT_NFT_OP_FLOWTABLE_UNREGISTER, > > +}; > > The previously reported problem with this as a static still exists, > correct? It does seem like this should live in nf_tables_api.c > doesn't it? Yes. Thank you. > 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 -- Linux-audit mailing list Linux-audit@redhat.com https://listman.redhat.com/mailman/listinfo/linux-audit