* [PATCH 6.18.y 0/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase
@ 2026-09-25 7:52 Benjamin Robin (Schneider Electric)
2026-09-25 7:52 ` [PATCH 6.18.y 1/2] rculist: add list_splice_rcu() for private lists Benjamin Robin (Schneider Electric)
2026-09-25 7:52 ` [PATCH 6.18.y 2/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Benjamin Robin (Schneider Electric)
0 siblings, 2 replies; 5+ messages in thread
From: Benjamin Robin (Schneider Electric) @ 2026-09-25 7:52 UTC (permalink / raw)
To: stable, Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman
Cc: miguel.gazquez, thomas.petazzoni, rcu, linux-kernel,
netfilter-devel, coreteam, netdev,
Benjamin Robin (Schneider Electric),
Sasha Levin
I backported an additional patch, which adds list_splice_rcu(), which is
required.
Signed-off-by: Benjamin Robin (Schneider Electric) <benjamin.robin@bootlin.com>
---
Pablo Neira Ayuso (2):
rculist: add list_splice_rcu() for private lists
netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase
include/linux/rculist.h | 29 +++++++++++++++++++++++++++++
net/netfilter/nf_tables_api.c | 8 ++++----
2 files changed, 33 insertions(+), 4 deletions(-)
---
base-commit: e8694cdbd7db99fa26f6e8c80a2a337e0de29a2f
change-id: 20260925-cve-2026-52988-6-18-9ce03769b44f
Best regards,
--
Benjamin Robin (Schneider Electric) <benjamin.robin@bootlin.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 6.18.y 1/2] rculist: add list_splice_rcu() for private lists
2026-09-25 7:52 [PATCH 6.18.y 0/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Benjamin Robin (Schneider Electric)
@ 2026-09-25 7:52 ` Benjamin Robin (Schneider Electric)
2026-09-25 14:23 ` Greg KH
2026-09-25 7:52 ` [PATCH 6.18.y 2/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Benjamin Robin (Schneider Electric)
1 sibling, 1 reply; 5+ messages in thread
From: Benjamin Robin (Schneider Electric) @ 2026-09-25 7:52 UTC (permalink / raw)
To: stable, Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman
Cc: miguel.gazquez, thomas.petazzoni, rcu, linux-kernel,
netfilter-devel, coreteam, netdev,
Benjamin Robin (Schneider Electric)
From: Pablo Neira Ayuso <pablo@netfilter.org>
[ Upstream commit f902877b635551513729bdf9a8d1422c4aab7741 ]
This patch adds a helper function, list_splice_rcu(), to safely splice
a private (non-RCU-protected) list into an RCU-protected list.
The function ensures that only the pointer visible to RCU readers
(prev->next) is updated using rcu_assign_pointer(), while the rest of
the list manipulations are performed with regular assignments, as the
source list is private and not visible to concurrent RCU readers.
This is useful for moving elements from a private list into a global
RCU-protected list, ensuring safe publication for RCU readers.
Subsystems with some sort of batching mechanism from userspace can
benefit from this new function.
The function __list_splice_rcu() has been added for clarity and to
follow the same pattern as in the existing list_splice*() interfaces,
where there is a check to ensure that the list to splice is not
empty. Note that __list_splice_rcu() has no documentation for this
reason.
Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/linux/rculist.h | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/include/linux/rculist.h b/include/linux/rculist.h
index 2abba7552605..e3bc44225692 100644
--- a/include/linux/rculist.h
+++ b/include/linux/rculist.h
@@ -261,6 +261,35 @@ static inline void list_replace_rcu(struct list_head *old,
old->prev = LIST_POISON2;
}
+static inline void __list_splice_rcu(struct list_head *list,
+ struct list_head *prev,
+ struct list_head *next)
+{
+ struct list_head *first = list->next;
+ struct list_head *last = list->prev;
+
+ last->next = next;
+ first->prev = prev;
+ next->prev = last;
+ rcu_assign_pointer(list_next_rcu(prev), first);
+}
+
+/**
+ * list_splice_rcu - splice a non-RCU list into an RCU-protected list,
+ * designed for stacks.
+ * @list: the non RCU-protected list to splice
+ * @head: the place in the existing RCU-protected list to splice
+ *
+ * The list pointed to by @head can be RCU-read traversed concurrently with
+ * this function.
+ */
+static inline void list_splice_rcu(struct list_head *list,
+ struct list_head *head)
+{
+ if (!list_empty(list))
+ __list_splice_rcu(list, head, head->next);
+}
+
/**
* __list_splice_init_rcu - join an RCU-protected list into an existing list.
* @list: the RCU-protected list to splice
--
2.55.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 6.18.y 2/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase
2026-09-25 7:52 [PATCH 6.18.y 0/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Benjamin Robin (Schneider Electric)
2026-09-25 7:52 ` [PATCH 6.18.y 1/2] rculist: add list_splice_rcu() for private lists Benjamin Robin (Schneider Electric)
@ 2026-09-25 7:52 ` Benjamin Robin (Schneider Electric)
2026-09-25 14:24 ` Greg KH
1 sibling, 1 reply; 5+ messages in thread
From: Benjamin Robin (Schneider Electric) @ 2026-09-25 7:52 UTC (permalink / raw)
To: stable, Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman
Cc: miguel.gazquez, thomas.petazzoni, rcu, linux-kernel,
netfilter-devel, coreteam, netdev,
Benjamin Robin (Schneider Electric),
Sasha Levin
From: Pablo Neira Ayuso <pablo@netfilter.org>
[ Upstream commit a6134e62dba2ea4f760b29d5226907f447c92400 ]
Publish new hooks in the list into the basechain/flowtable using
splice_list_rcu() to ensure netlink dump list traversal via rcu is safe
while concurrent ruleset update is going on.
Fixes: 78d9f48f7f44 ("netfilter: nf_tables: add devices to existing flowtable")
Fixes: b9703ed44ffb ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
net/netfilter/nf_tables_api.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index a3a66b6268cd..fa1ee5024d58 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -10863,8 +10863,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
nft_chain_commit_update(nft_trans_container_chain(trans));
nf_tables_chain_notify(&ctx, NFT_MSG_NEWCHAIN,
&nft_trans_chain_hooks(trans));
- list_splice(&nft_trans_chain_hooks(trans),
- &nft_trans_basechain(trans)->hook_list);
+ list_splice_rcu(&nft_trans_chain_hooks(trans),
+ &nft_trans_basechain(trans)->hook_list);
/* trans destroyed after rcu grace period */
} else {
nft_chain_commit_drop_policy(nft_trans_container_chain(trans));
@@ -10993,8 +10993,8 @@ static int nf_tables_commit(struct net *net, struct sk_buff *skb)
nft_trans_flowtable(trans),
&nft_trans_flowtable_hooks(trans),
NFT_MSG_NEWFLOWTABLE);
- list_splice(&nft_trans_flowtable_hooks(trans),
- &nft_trans_flowtable(trans)->hook_list);
+ list_splice_rcu(&nft_trans_flowtable_hooks(trans),
+ &nft_trans_flowtable(trans)->hook_list);
} else {
nft_clear(net, nft_trans_flowtable(trans));
nf_tables_flowtable_notify(&ctx,
--
2.55.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 6.18.y 1/2] rculist: add list_splice_rcu() for private lists
2026-09-25 7:52 ` [PATCH 6.18.y 1/2] rculist: add list_splice_rcu() for private lists Benjamin Robin (Schneider Electric)
@ 2026-09-25 14:23 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-09-25 14:23 UTC (permalink / raw)
To: Benjamin Robin (Schneider Electric)
Cc: stable, Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, miguel.gazquez, thomas.petazzoni, rcu,
linux-kernel, netfilter-devel, coreteam, netdev
On Fri, Sep 25, 2026 at 09:52:23AM +0200, Benjamin Robin (Schneider Electric) wrote:
> From: Pablo Neira Ayuso <pablo@netfilter.org>
>
> [ Upstream commit f902877b635551513729bdf9a8d1422c4aab7741 ]
>
> This patch adds a helper function, list_splice_rcu(), to safely splice
> a private (non-RCU-protected) list into an RCU-protected list.
>
> The function ensures that only the pointer visible to RCU readers
> (prev->next) is updated using rcu_assign_pointer(), while the rest of
> the list manipulations are performed with regular assignments, as the
> source list is private and not visible to concurrent RCU readers.
>
> This is useful for moving elements from a private list into a global
> RCU-protected list, ensuring safe publication for RCU readers.
> Subsystems with some sort of batching mechanism from userspace can
> benefit from this new function.
>
> The function __list_splice_rcu() has been added for clarity and to
> follow the same pattern as in the existing list_splice*() interfaces,
> where there is a check to ensure that the list to splice is not
> empty. Note that __list_splice_rcu() has no documentation for this
> reason.
>
> Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> include/linux/rculist.h | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
You did not sign off on this commit :(
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 6.18.y 2/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase
2026-09-25 7:52 ` [PATCH 6.18.y 2/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Benjamin Robin (Schneider Electric)
@ 2026-09-25 14:24 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2026-09-25 14:24 UTC (permalink / raw)
To: Benjamin Robin (Schneider Electric)
Cc: stable, Paul E. McKenney, Frederic Weisbecker, Neeraj Upadhyay,
Joel Fernandes, Josh Triplett, Boqun Feng, Uladzislau Rezki,
Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Zqiang,
Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
Phil Sutter, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, miguel.gazquez, thomas.petazzoni, rcu,
linux-kernel, netfilter-devel, coreteam, netdev, Sasha Levin
On Fri, Sep 25, 2026 at 09:52:24AM +0200, Benjamin Robin (Schneider Electric) wrote:
> From: Pablo Neira Ayuso <pablo@netfilter.org>
>
> [ Upstream commit a6134e62dba2ea4f760b29d5226907f447c92400 ]
>
> Publish new hooks in the list into the basechain/flowtable using
> splice_list_rcu() to ensure netlink dump list traversal via rcu is safe
> while concurrent ruleset update is going on.
>
> Fixes: 78d9f48f7f44 ("netfilter: nf_tables: add devices to existing flowtable")
> Fixes: b9703ed44ffb ("netfilter: nf_tables: support for adding new devices to an existing netdev chain")
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> net/netfilter/nf_tables_api.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Again, no signed-off-by :(
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-25 14:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-25 7:52 [PATCH 6.18.y 0/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Benjamin Robin (Schneider Electric)
2026-09-25 7:52 ` [PATCH 6.18.y 1/2] rculist: add list_splice_rcu() for private lists Benjamin Robin (Schneider Electric)
2026-09-25 14:23 ` Greg KH
2026-09-25 7:52 ` [PATCH 6.18.y 2/2] netfilter: nf_tables: join hook list via splice_list_rcu() in commit phase Benjamin Robin (Schneider Electric)
2026-09-25 14:24 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®