* [PATCH net 0/1] Netfilter fix for net
@ 2024-11-06 23:58 Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2024-11-06 23:58 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet, fw
Hi,
The following series contains a Netfilter fix:
1) Wait for rcu grace period after netdevice removal is reported via event.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-24-11-07
Thanks.
----------------------------------------------------------------
The following changes since commit 50ae879de107ca2fe2ca99180f6ba95770f32a62:
Merge tag 'nf-24-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf (2024-10-31 12:13:08 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-24-11-07
for you to fetch changes up to f22c3a7be6bbbfb2342ae7b21312cbfc12c7f632:
netfilter: nf_tables: wait for rcu grace period on net_device removal (2024-11-07 00:51:19 +0100)
----------------------------------------------------------------
netfilter pull request 24-11-07
----------------------------------------------------------------
Pablo Neira Ayuso (1):
netfilter: nf_tables: wait for rcu grace period on net_device removal
include/net/netfilter/nf_tables.h | 2 ++
net/netfilter/nf_tables_api.c | 41 ++++++++++++++++++++++++++++++++-------
2 files changed, 36 insertions(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 0/1] Netfilter fix for net
@ 2024-11-07 11:32 Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2024-11-07 11:32 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet, fw
v2: including kdoc update for new fields as per Paolo.
-o-
Hi,
The following series contains a Netfilter fix:
1) Wait for rcu grace period after netdevice removal is reported via event.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-24-11-07
Thanks.
----------------------------------------------------------------
The following changes since commit 50ae879de107ca2fe2ca99180f6ba95770f32a62:
Merge tag 'nf-24-10-31' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf (2024-10-31 12:13:08 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-24-11-07
for you to fetch changes up to c03d278fdf35e73dd0ec543b9b556876b9d9a8dc:
netfilter: nf_tables: wait for rcu grace period on net_device removal (2024-11-07 12:28:47 +0100)
----------------------------------------------------------------
netfilter pull request 24-11-07
----------------------------------------------------------------
Pablo Neira Ayuso (1):
netfilter: nf_tables: wait for rcu grace period on net_device removal
include/net/netfilter/nf_tables.h | 4 ++++
net/netfilter/nf_tables_api.c | 41 ++++++++++++++++++++++++++++++++-------
2 files changed, 38 insertions(+), 7 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 0/1] Netfilter fix for net
@ 2025-04-17 10:28 Pablo Neira Ayuso
2025-04-17 10:28 ` [PATCH net 1/1] netfilter: conntrack: fix erronous removal of offload bit Pablo Neira Ayuso
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2025-04-17 10:28 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet, fw, horms
Hi,
The following batch contains one Netfilter fix for net:
1) conntrack offload bit is erroneously unset in a race scenario,
from Florian Westphal.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git nf-25-04-17
Thanks.
----------------------------------------------------------------
The following changes since commit 747fb8413aaa36e4c988d45c4fe20d4c2b0778cd:
netlink: specs: ovs_vport: align with C codegen capabilities (2025-04-14 14:05:56 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git tags/nf-25-04-17
for you to fetch changes up to d2d31ea8cd80b9830cdab624e94f9d41178fc99d:
netfilter: conntrack: fix erronous removal of offload bit (2025-04-17 11:14:22 +0200)
----------------------------------------------------------------
netfilter pull request 25-04-17
----------------------------------------------------------------
Florian Westphal (1):
netfilter: conntrack: fix erronous removal of offload bit
net/netfilter/nf_flow_table_core.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/1] netfilter: conntrack: fix erronous removal of offload bit
2025-04-17 10:28 [PATCH net 0/1] Netfilter fix for net Pablo Neira Ayuso
@ 2025-04-17 10:28 ` Pablo Neira Ayuso
2025-04-17 13:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2025-04-17 10:28 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet, fw, horms
From: Florian Westphal <fw@strlen.de>
The blamed commit exposes a possible issue with flow_offload_teardown():
We might remove the offload bit of a conntrack entry that has been
offloaded again.
1. conntrack entry c1 is offloaded via flow f1 (f1->ct == c1).
2. f1 times out and is pushed back to slowpath, c1 offload bit is
removed. Due to bug, f1 is not unlinked from rhashtable right away.
3. a new packet arrives for the flow and re-offload is triggered, i.e.
f2->ct == c1. This is because lookup in flowtable skip entries with
teardown bit set.
4. Next flowtable gc cycle finds f1 again
5. flow_offload_teardown() is called again for f1 and c1 offload bit is
removed again, even though we have f2 referencing the same entry.
This is harmless, but clearly not correct.
Fix the bug that exposes this: set 'teardown = true' to have the gc
callback unlink the flowtable entry from the table right away instead of
the unintentional defer to the next round.
Also prevent flow_offload_teardown() from fixing up the ct state more than
once: We could also be called from the data path or a notifier, not only
from the flowtable gc callback.
NF_FLOW_TEARDOWN can never be unset, so we can use it as synchronization
point: if we observe did not see a 0 -> 1 transition, then another CPU
is already doing the ct state fixups for us.
Fixes: 03428ca5cee9 ("netfilter: conntrack: rework offload nf_conn timeout extension logic")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_flow_table_core.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index 9d8361526f82..9441ac3d8c1a 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -383,8 +383,8 @@ static void flow_offload_del(struct nf_flowtable *flow_table,
void flow_offload_teardown(struct flow_offload *flow)
{
clear_bit(IPS_OFFLOAD_BIT, &flow->ct->status);
- set_bit(NF_FLOW_TEARDOWN, &flow->flags);
- flow_offload_fixup_ct(flow);
+ if (!test_and_set_bit(NF_FLOW_TEARDOWN, &flow->flags))
+ flow_offload_fixup_ct(flow);
}
EXPORT_SYMBOL_GPL(flow_offload_teardown);
@@ -558,10 +558,12 @@ static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
if (nf_flow_has_expired(flow) ||
nf_ct_is_dying(flow->ct) ||
- nf_flow_custom_gc(flow_table, flow))
+ nf_flow_custom_gc(flow_table, flow)) {
flow_offload_teardown(flow);
- else if (!teardown)
+ teardown = true;
+ } else if (!teardown) {
nf_flow_table_extend_ct_timeout(flow->ct);
+ }
if (teardown) {
if (test_bit(NF_FLOW_HW, &flow->flags)) {
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 1/1] netfilter: conntrack: fix erronous removal of offload bit
2025-04-17 10:28 ` [PATCH net 1/1] netfilter: conntrack: fix erronous removal of offload bit Pablo Neira Ayuso
@ 2025-04-17 13:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-04-17 13:30 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: netfilter-devel, davem, netdev, kuba, pabeni, edumazet, fw, horms
Hello:
This patch was applied to netdev/net.git (main)
by Pablo Neira Ayuso <pablo@netfilter.org>:
On Thu, 17 Apr 2025 12:28:47 +0200 you wrote:
> From: Florian Westphal <fw@strlen.de>
>
> The blamed commit exposes a possible issue with flow_offload_teardown():
> We might remove the offload bit of a conntrack entry that has been
> offloaded again.
>
> 1. conntrack entry c1 is offloaded via flow f1 (f1->ct == c1).
> 2. f1 times out and is pushed back to slowpath, c1 offload bit is
> removed. Due to bug, f1 is not unlinked from rhashtable right away.
> 3. a new packet arrives for the flow and re-offload is triggered, i.e.
> f2->ct == c1. This is because lookup in flowtable skip entries with
> teardown bit set.
> 4. Next flowtable gc cycle finds f1 again
> 5. flow_offload_teardown() is called again for f1 and c1 offload bit is
> removed again, even though we have f2 referencing the same entry.
>
> [...]
Here is the summary with links:
- [net,1/1] netfilter: conntrack: fix erronous removal of offload bit
https://git.kernel.org/netdev/net/c/d2d31ea8cd80
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-17 13:30 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-17 10:28 [PATCH net 0/1] Netfilter fix for net Pablo Neira Ayuso
2025-04-17 10:28 ` [PATCH net 1/1] netfilter: conntrack: fix erronous removal of offload bit Pablo Neira Ayuso
2025-04-17 13:30 ` patchwork-bot+netdevbpf
-- strict thread matches above, loose matches on Subject: below --
2024-11-07 11:32 [PATCH net 0/1] Netfilter fix for net Pablo Neira Ayuso
2024-11-06 23:58 Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).