Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp562084ybt; Wed, 24 Jun 2020 06:04:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6VlYBIE0l1yeahbSTNDRFj4B5BNeQom0Wt1jfSYev3FLFpecXoIAbo8r8cZKt3Qmyn4YR X-Received: by 2002:a05:6402:148d:: with SMTP id e13mr27368002edv.200.1593003882433; Wed, 24 Jun 2020 06:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593003882; cv=none; d=google.com; s=arc-20160816; b=1LDgaOvi2FhbJoTDQAky/UzwleBiTyYUfzPeIsTjOZj6upBJzYzgeSK5m980/pWBJ/ /zGuvYPsdhWLc17ogOT9QDymYHwWi4APy+iXrHjZeRUT+A5mnm9nZDa7PYWGztrTaZv/ kqFy1sG23JhpC32Z3TiIMMloS17MkzaKjTdu8E3qv94SRT5jslAl//tF4UhkVgATuW+c eqPF/zw34tlfLU7I5tXsg2cCbmMYv+URgWAdFEH2eQMhHpNw03O5hfe0laxsCf+1GHn6 PxAlmtsjBOQZuo0oLaVUZ+e2O/9kMGvqqtWT+e2HrNN+giqRQyEluCn1VSH2NRgCKzd6 yhPA== 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; bh=EF/6oneMX0mtsOG8bLuymPtOCuwAncInq3D5ec5F8Gc=; b=M62T4Nf1YkHzqTDKmO2PeQ7OXPLtKYcrptf08O9kWjP8li+3e2wAc0Dl5Qf2TRahqC ZGPm/BSPTSNB282MprrGb0/PjHpLc2H1/kZN5iWEyrsfqBgfChD5Y6/jCtF+e4ojRnFs TtT1NLilHslwzu0y4f+bm0YibP7Mr5Ms0FXKpYWRQaf/VJM3RVmcgyRulBok+Gt84tbF pPfYot6Z7ZrLHiZgqp9BNvE7ojJf52BgJ376g776CSYXjClSYI3hNN83NqypU5bWBL11 fZ7UDxAxWaeer4mXNQ2rrlyNCDWT5Zs4JdTVSRAfiDlcRafUei6hUAe7KWqyZZfeMTP3 0y5w== 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 q19si5751709edr.36.2020.06.24.06.04.17; Wed, 24 Jun 2020 06:04:42 -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 S2390910AbgFXNDJ (ORCPT + 99 others); Wed, 24 Jun 2020 09:03:09 -0400 Received: from correo.us.es ([193.147.175.20]:42552 "EHLO mail.us.es" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390317AbgFXNDI (ORCPT ); Wed, 24 Jun 2020 09:03:08 -0400 Received: from antivirus1-rhel7.int (unknown [192.168.2.11]) by mail.us.es (Postfix) with ESMTP id 9CC7E1C442D for ; Wed, 24 Jun 2020 15:03:07 +0200 (CEST) Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 8EA14DA73D for ; Wed, 24 Jun 2020 15:03:07 +0200 (CEST) Received: by antivirus1-rhel7.int (Postfix, from userid 99) id 76E94DA722; Wed, 24 Jun 2020 15:03:07 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on antivirus1-rhel7.int X-Spam-Level: X-Spam-Status: No, score=-108.2 required=7.5 tests=ALL_TRUSTED,BAYES_50, SMTPAUTH_US2,USER_IN_WHITELIST autolearn=disabled version=3.4.1 Received: from antivirus1-rhel7.int (localhost [127.0.0.1]) by antivirus1-rhel7.int (Postfix) with ESMTP id 483A8DA73D; Wed, 24 Jun 2020 15:03:05 +0200 (CEST) Received: from 192.168.1.97 (192.168.1.97) by antivirus1-rhel7.int (F-Secure/fsigk_smtp/550/antivirus1-rhel7.int); Wed, 24 Jun 2020 15:03:05 +0200 (CEST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/antivirus1-rhel7.int) Received: from us.es (unknown [90.77.255.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: 1984lsi) by entrada.int (Postfix) with ESMTPSA id 10BDD42EF42B; Wed, 24 Jun 2020 15:03:05 +0200 (CEST) Date: Wed, 24 Jun 2020 15:03:04 +0200 X-SMTPAUTHUS: auth mail.us.es From: Pablo Neira Ayuso To: Richard Guy Briggs Cc: Linux-Audit Mailing List , LKML , netfilter-devel@vger.kernel.org, Paul Moore , sgrubb@redhat.com, omosnace@redhat.com, fw@strlen.de, twoerner@redhat.com, eparis@parisplace.org, tgraf@infradead.org Subject: Re: [PATCH ghak124 v3] audit: log nftables configuration change events Message-ID: <20200624130304.GA549@salvia> References: <20200624100346.GA11986@salvia> <20200624123423.r2gypsdii6xgiywy@madcap2.tricolour.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200624123423.r2gypsdii6xgiywy@madcap2.tricolour.ca> User-Agent: Mutt/1.10.1 (2018-07-13) X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 24, 2020 at 08:34:23AM -0400, Richard Guy Briggs wrote: > On 2020-06-24 12:03, Pablo Neira Ayuso wrote: > > On Thu, Jun 04, 2020 at 09:20:49AM -0400, Richard Guy Briggs wrote: [...] > > > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > > > index 3558e76e2733..b9e7440cc87d 100644 > > > --- a/net/netfilter/nf_tables_api.c > > > +++ b/net/netfilter/nf_tables_api.c > > > @@ -12,6 +12,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include > > > #include > > > #include > > > @@ -693,6 +694,16 @@ static void nf_tables_table_notify(const struct nft_ctx *ctx, int event) > > > { > > > struct sk_buff *skb; > > > int err; > > > + char *buf = kasprintf(GFP_KERNEL, "%s:%llu;?:0", > > > + ctx->table->name, ctx->table->handle); > > > + > > > + audit_log_nfcfg(buf, > > > + ctx->family, > > > + ctx->table->use, > > > + event == NFT_MSG_NEWTABLE ? > > > + AUDIT_NFT_OP_TABLE_REGISTER : > > > + AUDIT_NFT_OP_TABLE_UNREGISTER); > > > + kfree(buf); > > > > As a follow up: Would you wrap this code into a function? > > > > nft_table_audit() > > > > Same thing for other pieces of code below. > > If I'm guessing right, you are asking for a supplementary follow-up > cleanup patch to this one (or are you nacking this patch)? No nack, it's just that I'd prefer to see this wrapped in a function. I think your patch is already in the audit tree. > Also, I gather you would like to see the kasprintf and kfree hidden in > nft_table_audit(), handing this function at least 8 parameters? This > sounds pretty messy given the format of the table field. I think you can pass ctx and the specific object, e.g. table, in most cases? There is also event and the gfp_flags. That counts 4 here, but maybe I'm overlooking something. Thanks.