Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp698909pxf; Thu, 18 Mar 2021 09:33:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEwVA89MwYnPUhfEmL5KDfM4PlwsaRoAp3i7jiywo63HwfmzufEiA9akjxfzQl/QC0i7Jz X-Received: by 2002:aa7:db15:: with SMTP id t21mr4703524eds.145.1616085189326; Thu, 18 Mar 2021 09:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616085189; cv=none; d=google.com; s=arc-20160816; b=TgOZCEUl/e+TEV3ydyRoQNhoAA7RwbPp9Ranr1x7q1YzQy89ddOvVLgFj/VUMTKRRv os3EB8wJhIbREXXa9h+MHhyw96/qlPxoYZqKA/qEW+KKC5hVIv5u7TGIxE7dVCIZh/mM C5nBsR8T8rCcIXqbvv87vumFeNafHMNnZkzpWykFeChnx4tzSuszbbobONrIPkQhPrgX xhNrYShdQP8FYR0hBfxf+fv/u5GNXTFs+o7zUmNJuPxt8ONvRrh+3KsGq3DJkUzKYXSS 7sQZvjQJksc6FYiJ87Pd9TnIi0kc95Yco21CDErOF+A3ILIQAKiZiScgz5ef/KEWkDjE O/Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date; bh=AjaA/zCM8QTvvfChQCQCcwK3SdCn2EsQg/FjatqMatM=; b=uhqXriyVn8iLS7UgSLNvYD6b7Gi9xu37JEyKbnbvIzCQsFaXJ0JOxnbYYZzoLFCuJU uIc6OBU8AqQoDicFX9n11Blx+Skq3tPllMrx0Xk6u62/BEweGT+hYsXLUy801Vm+lhIW W2tb/roQsdDVdSXGm6Ysq544O1T3RWTxC8leERolZ8OKtwrCfux65PHniVl5ZKh44Sqp HKUYO1I/yaLqPdvbNxyoqwZlspOE0RoPssnIMmLqJqWfeNU5ybkj5iD4hcXCJBSWkYCR c6moX8/uLfv3rFq7X4QDl7vMVRAsBCff0PoTWURF3+g2sfYvhKOfrdrujqWc7Tw43GXs CraQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si1981527eja.559.2021.03.18.09.32.46; Thu, 18 Mar 2021 09:33:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231963AbhCRQbF (ORCPT + 99 others); Thu, 18 Mar 2021 12:31:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231833AbhCRQaj (ORCPT ); Thu, 18 Mar 2021 12:30:39 -0400 Received: from orbyte.nwl.cc (orbyte.nwl.cc [IPv6:2001:41d0:e:133a::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F000C06174A; Thu, 18 Mar 2021 09:30:39 -0700 (PDT) Received: from n0-1 by orbyte.nwl.cc with local (Exim 4.94) (envelope-from ) id 1lMvXc-0001zd-0z; Thu, 18 Mar 2021 17:30:32 +0100 Date: Thu, 18 Mar 2021 17:30:32 +0100 From: Phil Sutter To: Richard Guy Briggs Cc: Linux-Audit Mailing List , LKML , netfilter-devel@vger.kernel.org, Paul Moore , Eric Paris , Steve Grubb , Florian Westphal , twoerner@redhat.com, tgraf@infradead.org, dan.carpenter@oracle.com, Jones Desougi Subject: Re: [PATCH] audit: log nftables configuration change events once per table Message-ID: <20210318163032.GS5298@orbyte.nwl.cc> Mail-Followup-To: Phil Sutter , Richard Guy Briggs , Linux-Audit Mailing List , LKML , netfilter-devel@vger.kernel.org, Paul Moore , Eric Paris , Steve Grubb , Florian Westphal , twoerner@redhat.com, tgraf@infradead.org, dan.carpenter@oracle.com, Jones Desougi References: <7e73ce4aa84b2e46e650b5727ee7a8244ec4a0ac.1616078123.git.rgb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7e73ce4aa84b2e46e650b5727ee7a8244ec4a0ac.1616078123.git.rgb@redhat.com> Sender: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thu, Mar 18, 2021 at 11:39:52AM -0400, 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. This looks much better, a few remarks below: [...] > +static const u8 nft2audit_op[] = { // 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, > + /* NFT_MSG_MAX */ AUDIT_NFT_OP_INVALID, > +}; NFT_MSG_MAX is itself not a valid message, it serves merely as an upper bound for arrays, loops or sanity checks. You will never see it in trans->msg_type. Since enum nf_tables_msg_types contains consecutive values from 0 to NFT_MSG_MAX, you could write the above more explicitly: | static const u8 nft2audit_op[NFT_MSG_MAX] = { | [NFT_MSG_NEWTABLE] = AUDIT_NFT_OP_TABLE_REGISTER, | [NFT_MSG_GETTABLE] = AUDIT_NFT_OP_INVALID, | [NFT_MSG_DELTABLE] = AUDIT_NFT_OP_TABLE_UNREGISTER, (And so forth.) Not a must, but it clarifies the 1:1 mapping between index and said enum. Sadly, AUDIT_NFT_OP_INVALID is non-zero. Otherwise one could skip all uninteresting ones. [...] > @@ -6278,12 +6219,11 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb) > filter->type != NFT_OBJECT_UNSPEC && > obj->ops->type->type != filter->type) > goto cont; > - > if (reset) { > char *buf = kasprintf(GFP_ATOMIC, > - "%s:%llu;?:0", > + "%s:%u", > table->name, > - table->handle); > + net->nft.base_seq); > > audit_log_nfcfg(buf, > family, Why did you leave the object-related logs in place? They should reappear at commit time just like chains and sets for instance, no? Thanks, Phil