From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.netfilter.org (mail.netfilter.org [217.70.190.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F48643B6E0; Mon, 10 Aug 2026 19:06:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.190.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786388807; cv=none; b=joMm5FlFJTCe/dmfIy9VUw3/VasT7/vgzrleY1f/h5wk5qfEREsqpo3UBryI7DR/t5SyII1F4YHL/YK+OxfMPKrIpy4uek3ZLua+tMwtdITPS3HLRRjLto9Jl9X8inSkl9OxGmCceTWT6NjQ2XnPt+aVHvUYF6wJ4aNr9pVId98= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786388807; c=relaxed/simple; bh=GL+Br0Rwj9zL9FCNPQ5eEuZiTA8NKQRuePOnUOn+gs8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Er3g+SrotxRY1Q9louEbE9BUOl6Ui7XXpzONAwE2Y6+g2X3oo3vY3MbkxpAB+tNMZy5cD8A4aJA8t9JwSym7F5mVAkC8o/dmQODYhz1VgoOvQWPoYjr4y+N4uvW+q7ReHkGd9sEL0AeWlO39pOCMZaf9WFZvhbRbL9K5jSZdwSM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org; spf=pass smtp.mailfrom=netfilter.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b=qjgpXgnd; arc=none smtp.client-ip=217.70.190.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=netfilter.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=netfilter.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=netfilter.org header.i=@netfilter.org header.b="qjgpXgnd" Received: from localhost.localdomain (mail-agni [217.70.190.124]) by mail.netfilter.org (Postfix) with ESMTPSA id 4809A60293; Mon, 10 Aug 2026 21:06:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netfilter.org; s=2025; t=1786388803; bh=l0yN1YmE+COjcQTKO9oKz51JZ7nGnz8UaPG7meywNYU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qjgpXgnd6JDuVxafQs9/wjRuQqGUvpPB0kocjxmi/IhPoE41gfJ3+jj0p8L5osOT0 IotSd9pnwiTmzOxPqw5q/FSuqvhzu48KBHgGQ6ATJk4oAOYQMquI0Ql+1pACHNUr77 UPt1t0SoyXhB6IWzm/Gr5osqvDKdKgH6YsXN4AYxDgICw0pN04R4kXWIFnFHtRS2wF hJZWREAhF6EWpeFjTvcXqYM8s8seKXpTSal9R8fU5Onmf0YSbxPIhJXA99jvwNLzpA 1oPtRaXID6Sx0Murs53T+lJ7V94EMNgrpNWwCH8dsvY1ML3n1j/BCfwn8Ryt8Re6tA Px34kLUPXj33A== From: Pablo Neira Ayuso To: netfilter-devel@vger.kernel.org Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, horms@kernel.org, fw@strlen.de, ja@ssi.bg Subject: [PATCH net 07/13] netfilter: nfnetlink_log: wait for rcu grace period before freeing pernet state Date: Mon, 10 Aug 2026 21:06:15 +0200 Message-ID: <20260810190621.894119-8-pablo@netfilter.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260810190621.894119-1-pablo@netfilter.org> References: <20260810190621.894119-1-pablo@netfilter.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Florian Westphal sashiko reports: "nfnl_log_net_exit() calls nf_log_unset(), which clears the logger pointer without an RCU grace period. Immediately after, ops_free_list() frees the per-net state while concurrent packets might still be executing nf_log_packet() under rcu_read_lock()." Clear the pointer via .pre_exit to make sure rcu readers have completed before pernet storage is free'd. The change in nf_log_syslog.c is only done for consistency: it doesn't use pernet data. Link: https://sashiko.dev/#/patchset/20260731151806.849724-1-pablo%40netfilter.org Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso --- net/netfilter/nf_log_syslog.c | 4 ++-- net/netfilter/nfnetlink_log.c | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c index e37b09b3203b..5ffde27d450a 100644 --- a/net/netfilter/nf_log_syslog.c +++ b/net/netfilter/nf_log_syslog.c @@ -1014,7 +1014,7 @@ static int __net_init nf_log_syslog_net_init(struct net *net) return ret; } -static void __net_exit nf_log_syslog_net_exit(struct net *net) +static void __net_exit nf_log_syslog_net_pre_exit(struct net *net) { nf_log_unset(net, &nf_ip_logger); nf_log_unset(net, &nf_arp_logger); @@ -1025,7 +1025,7 @@ static void __net_exit nf_log_syslog_net_exit(struct net *net) static struct pernet_operations nf_log_syslog_net_ops = { .init = nf_log_syslog_net_init, - .exit = nf_log_syslog_net_exit, + .pre_exit = nf_log_syslog_net_pre_exit, }; static int __init nf_log_syslog_init(void) diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index 5fee61b3813c..6c7fa2ed34f5 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -1170,21 +1170,26 @@ static int __net_init nfnl_log_net_init(struct net *net) return 0; } -static void __net_exit nfnl_log_net_exit(struct net *net) +static void __net_exit nfnl_log_net_pre_exit(struct net *net) { - struct nfnl_log_net *log = nfnl_log_pernet(net); - unsigned int i; - #ifdef CONFIG_PROC_FS remove_proc_entry("nfnetlink_log", net->nf.proc_netfilter); #endif nf_log_unset(net, &nfulnl_logger); +} + +static void __net_exit nfnl_log_net_exit(struct net *net) +{ + struct nfnl_log_net *log = nfnl_log_pernet(net); + unsigned int i; + for (i = 0; i < INSTANCE_BUCKETS; i++) WARN_ON_ONCE(!hlist_empty(&log->instance_table[i])); } static struct pernet_operations nfnl_log_net_ops = { .init = nfnl_log_net_init, + .pre_exit = nfnl_log_net_pre_exit, .exit = nfnl_log_net_exit, .id = &nfnl_log_net_id, .size = sizeof(struct nfnl_log_net), -- 2.47.3