Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp994399ybm; Wed, 27 May 2020 13:12:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwprOVEoonuPkiQX5958WOdY2idBlb4pNTnfC/OOrj881EYvAuvnzYTUWDbIw11irnxWyoE X-Received: by 2002:aa7:d487:: with SMTP id b7mr25606153edr.351.1590610332819; Wed, 27 May 2020 13:12:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590610332; cv=none; d=google.com; s=arc-20160816; b=zlXWzj9juCwNv6vwb/CpaQIecYtl7GJY5UpaGxWw3n/TDWUGqjyejqLeBah9oJDPGN L55u+u5eBE8XR8HgoHuCHR4LpK1vAPBFHeIdBiCNB1qxwmP9El+0VxLqFifnX2/f4C5Q UtWsAxr/sbb2he7lZkjdeBtOs4yHhslTb1CFxn1hz/JufiULNwfw89OTjzt31yBDYXIL W2cpdP5lQ5boRoAbRM0f/6/MsI7rgOxQPAH7+mgRxqVMTPLEhred6lLlG2u5Z67fPqyv QoLmQvy2bwOVGXuDuIPtgXCPQIkzWaMMPOScN2Bzc6ThJm4kOiIRzTSTVvVwrzVz18Ca DUhA== 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=b6gcAPnfrlYQOYRJNXEJgRGe2DQxoKXAPrm3yE8BG3g=; b=e2RcQu/HUsmLulYM1ycgGZWJz0YkD9yBOgDGeiueF5fpDYjpHQIhBtmecyP+GAGAMi Fh79tmLAWaoVOjqTCAok7KeuPs5N3zJNglSGGSpjo+DHnZ7O7+FGgt5tJpmT5IE/e4X8 zBBNnQvJbMxBZ3qBeac2IwszTOa1jOb2f1slP1gZvYFME+s8a2RCFCPohpOd1TYMO1C6 T5OJBw+UEvOuOwfPlrIzIqVoih74cjLj9wCPo3jhBV1//CB8NIPf5UvovQRXce45Tjtu +jYdboSA2SpcEiTE1V5NPvhR/B4ybYvntFAZ2Zgkbhp3Iiqhl8gm5izhzXlNO4S0fXUD 9emA== 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 be4si2204663edb.610.2020.05.27.13.11.45; Wed, 27 May 2020 13:12:12 -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 S1728492AbgE0UGD (ORCPT + 99 others); Wed, 27 May 2020 16:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726114AbgE0UGD (ORCPT ); Wed, 27 May 2020 16:06:03 -0400 X-Greylist: delayed 18763 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 27 May 2020 13:06:03 PDT Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6055EC05BD1E; Wed, 27 May 2020 13:06:03 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1je2JN-0002DO-Fg; Wed, 27 May 2020 22:06:01 +0200 Date: Wed, 27 May 2020 22:06:01 +0200 From: Florian Westphal To: Richard Guy Briggs Cc: Florian Westphal , Linux-Audit Mailing List , LKML , netfilter-devel@vger.kernel.org, Paul Moore , sgrubb@redhat.com, omosnace@redhat.com, twoerner@redhat.com, eparis@parisplace.org, tgraf@infradead.org Subject: Re: [PATCH ghak124 v1] audit: log nftables configuration change events Message-ID: <20200527200601.GJ2915@breakpoint.cc> References: <20200527145317.GI2915@breakpoint.cc> <20200527152443.7axktc2im3zpvk37@madcap2.tricolour.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200527152443.7axktc2im3zpvk37@madcap2.tricolour.ca> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Richard Guy Briggs wrote: > Well, we are only logging "some change", so is it necessary to log the > generation count to show that? Is the generation count of specific > interest? No, its of no specific interest. I just worded this poorly. If the generation id increments, then something has been changed by the batch, thats all. > > (After that, kernel can't back down anymore, i.e. all errors are > > caught/handled beforehand). > > I did think of recording all failed attempts too, but coding that would > be more effort. It is worth doing if it is deemed important, > particularly for permission issues (as opposed to resource limits or > packet format errors. This would be more of interest to a security > officer rather than a network technician, but the latter may find it > useful for debugging. The permission check is done early, in nfnetlink_rcv() (search for EPERM), you would need to add an audit call there if thats relevant for audit purposes. > > If its 'any config change', then you also need to handle adds > > or delete from sets/maps, since that may allow something that wasn't > > allowed before, e.g. consider > > > > ip saddr @trused accept > > > > and then, later on, > > nft add element ip filter @trusted { 10.0.0.0/8, 192.168.0.1 } > > > > This would not add a table, or chain, or set, but it does implicitly > > alter the ruleset. > > Ah, ok, so yes, we would need that too. I see family and table in > there, op is evident. Is there a useful value we can use in the > "entries" field? Maybe the handle of the set that the element was added to. Each set, rule, chain, ... has a kernel-assigned number that serves as a unique identifier. > > Is that record format expected to emit the current number of chains? > > I was aiming for a relevant value such as perhaps the new rule number or > the rule number being deleted. In that case, use the handle, which is a u64 with a unique value (for a given table). > > Since table names can be anything in nf_tables (they have no special > > properties anymore), the table name is interesting from a informational > > pov, but not super interesting. > > I don't think we need to be able to completely reconstruct the > tables/chains/rules from the information in the audit log, but be aware > of who is changing what when. Ok. Have a look at nf_tables_fill_gen_info() in that case, you probably want to emit at least the pid and task info, unless audit doesn't add that already anyway. > > Consider a batch update that commits 100 new rules in chain x, > > this would result in 100 audit_log_nfcfg() calls, each with the > > same information. > > So rule number would be a useful differentiator here. Ok. Yes, that is available (rule->handle).