Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp701226pxf; Wed, 31 Mar 2021 13:55:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLR0YisyFu/4Bvi5D/QoRBgp/ocAyco7jjziuFhlcU/GHn9VH09liPPzVaS91qSv6aRV9w X-Received: by 2002:a17:907:778d:: with SMTP id ky13mr5642722ejc.291.1617224150112; Wed, 31 Mar 2021 13:55:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617224150; cv=none; d=google.com; s=arc-20160816; b=yi5lDor9TNo5ZBuTw5fGPGU0SJHsHu8O1kbvOEPBuDd/KSDMg2G15MbVj8qkjMif3q QBPq14i0vGS6NdvoZKY7ZaGUuedQwB+OllWMmN1PYEFlOrC2PH6gCXYqP9Y1BDr+8N/p d/L9WbuH2bd/VqD1mVnU7WSr0MpJEZjxsmlM0xbciKvu/VDi8MfCw2AYPRcDhESHRvPM kj0MwXPr5A58Khq9cMz5PL0XPz3fa1C8lj+ZQjp64hcwL5F/JRaGZ1qx69TdW2NyhDzX v1SdoMNKSbaX2CZVAxhbRctIdc7y8P2tw0FvEyf+OX3MLvClSIZI5/k04oWyheWtB6Ne BZLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=xgbyKFWQqZbg2Gy7gmQQyJMfhuaX+Jv3XqHiA6Dpe28=; b=WCCuO/TufQCJ63m2P55gpIUnL4EzbMNAYZto6ljDDgZ27jcRJG8CyDYGg7Cz/2m9uB vmRbANK3sxSeL9WgQEsb93swDGJMuQN1s8yATU6CEl3aVRxYJFIdI3cqnV8oh48Op6mv Atoz2qQ5PeqBcg92zssuOUj9L3CN7D0vkUHqV6tdQk8tgWZPNW//G+yiKK+bTP1E5986 P0Y2X6t+uqoLmZA4gtst7rK6gjUe30Cd2A+2Vxyj3p192Ez3PW08PDyC69f/8e1qS1ka IwNGzJSXRzHBPb93CxD7OveFplitz4IZJTVWTUZxylip4cJbD20ImBqe6m9lw5arhxMu 6u+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BQOfyHB5; 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 mp39si2411487ejc.182.2021.03.31.13.55.28; Wed, 31 Mar 2021 13:55:50 -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=BQOfyHB5; 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 S232207AbhCaUxr (ORCPT + 99 others); Wed, 31 Mar 2021 16:53:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:56084 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232741AbhCaUxe (ORCPT ); Wed, 31 Mar 2021 16:53:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617224013; 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=xgbyKFWQqZbg2Gy7gmQQyJMfhuaX+Jv3XqHiA6Dpe28=; b=BQOfyHB5TCmTCbGMb4YY4zlgJAGqYsJNQXsj7RJ7dGY3tgcmmAl78imANwvbey/ebBDFHn tbDSqHt+DSl6xmiAf3j60tjZo50mtQBIeZlDb2ZVkZz3HlVWUTSkqhWCSVE8nEfhDB3L+y vvlWjr3kElDLDRqmzr20d5yZoMkMYJ8= 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-400-sgfKZxsEP7qAfqAt2QBDkQ-1; Wed, 31 Mar 2021 16:53:25 -0400 X-MC-Unique: sgfKZxsEP7qAfqAt2QBDkQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38B71801814; Wed, 31 Mar 2021 20:53:23 +0000 (UTC) Received: from madcap2.tricolour.ca (unknown [10.10.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 717156A8FA; Wed, 31 Mar 2021 20:53:13 +0000 (UTC) Date: Wed, 31 Mar 2021 16:53:10 -0400 From: Richard Guy Briggs To: Pablo Neira Ayuso Cc: Linux-Audit Mailing List , LKML , netfilter-devel@vger.kernel.org, Paul Moore , Eric Paris , Steve Grubb , Florian Westphal , Phil Sutter , twoerner@redhat.com, tgraf@infradead.org, dan.carpenter@oracle.com, Jones Desougi Subject: Re: [PATCH v5] audit: log nftables configuration change events once per table Message-ID: <20210331205310.GA3141668@madcap2.tricolour.ca> References: <28de34275f58b45fd4626a92ccae96b6d2b4e287.1616702731.git.rgb@redhat.com> <20210331202230.GA4109@salvia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331202230.GA4109@salvia> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-03-31 22:22, Pablo Neira Ayuso wrote: > On Fri, Mar 26, 2021 at 01:38:59PM -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. > > > > Indicate the op as the most significant operation in the event. > > There's a UAF, Florian reported. I'm attaching an incremental fix. > > nf_tables_commit_audit_collect() refers to the trans object which > might have been already released. Got it. Thanks Pablo. I didn't see it when running nft-test.py Where was it reported? Here I tried to stay out of the way by putting that call at the end of the loop but that was obviously a mistake in hindsight. :-) > commit e4d272948d25b66d86fc241cefd95281bfb1079e > Author: Pablo Neira Ayuso > Date: Wed Mar 31 22:19:51 2021 +0200 > > netfilter: nf_tables: use-after-free > > Signed-off-by: Pablo Neira Ayuso > > diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c > index 5dd4bb7cabf5..01674c0d9103 100644 > --- a/net/netfilter/nf_tables_api.c > +++ b/net/netfilter/nf_tables_api.c > @@ -8063,6 +8063,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) > net->nft.gencursor = nft_gencursor_next(net); > > list_for_each_entry_safe(trans, next, &net->nft.commit_list, list) { > + nf_tables_commit_audit_collect(&adl, trans->ctx.table, > + trans->msg_type); > switch (trans->msg_type) { > case NFT_MSG_NEWTABLE: > if (nft_trans_table_update(trans)) { > @@ -8211,8 +8213,6 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb) > } > break; > } > - nf_tables_commit_audit_collect(&adl, trans->ctx.table, > - trans->msg_type); > } > > nft_commit_notify(net, NETLINK_CB(skb).portid); - 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