* [PATCH nf] netfilter: nfnetlink_log: wait for rcu grace period before freeing pernet state
@ 2026-08-03 8:43 Florian Westphal
2026-08-03 18:32 ` Florian Westphal
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2026-08-03 8:43 UTC (permalink / raw)
To: netfilter-devel; +Cc: 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 <fw@strlen.de>
---
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.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf] netfilter: nfnetlink_log: wait for rcu grace period before freeing pernet state
2026-08-03 8:43 [PATCH nf] netfilter: nfnetlink_log: wait for rcu grace period before freeing pernet state Florian Westphal
@ 2026-08-03 18:32 ` Florian Westphal
0 siblings, 0 replies; 2+ messages in thread
From: Florian Westphal @ 2026-08-03 18:32 UTC (permalink / raw)
To: netfilter-devel
Florian Westphal <fw@strlen.de> wrote:
> 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.
Forgot to add:
Fixes: 9368a53c471b ("netfilter: nfnetlink_log: add net namespace support for nfnetlink_log")
The sashiko review can be ignored, its correct but there is a pending
ebt_nflog patch that resolves the issue.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-03 18:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-03 8:43 [PATCH nf] netfilter: nfnetlink_log: wait for rcu grace period before freeing pernet state Florian Westphal
2026-08-03 18:32 ` Florian Westphal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.