* Re: [PATCH net-next] sfc: wait for RCU readers before reclaiming failed CT entries
2026-12-03 3:15 [PATCH net-next] sfc: wait for RCU readers before reclaiming failed CT entries Jaeyeong Lee
@ 2026-12-03 3:19 ` netdev-bot+sinfo
2026-12-04 3:46 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sinfo @ 2026-12-03 3:19 UTC (permalink / raw)
To: Jaeyeong Lee
Cc: Andy Moreton, Alex Austin, netdev, linux-net-drivers, Andrew Lunn,
David S.Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please
mention the device (and if relevant firmware version) used for
testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] sfc: wait for RCU readers before reclaiming failed CT entries
2026-12-03 3:15 [PATCH net-next] sfc: wait for RCU readers before reclaiming failed CT entries Jaeyeong Lee
2026-12-03 3:19 ` netdev-bot+sinfo
@ 2026-12-04 3:46 ` netdev-bot+sashiko
1 sibling, 0 replies; 3+ messages in thread
From: netdev-bot+sashiko @ 2026-12-04 3:46 UTC (permalink / raw)
To: lee
Cc: andy.moreton, alex.austin, netdev, linux-net-drivers,
andrew+netdev, davem, edumazet, kuba, pabeni
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] Nothing in the tree shows that the race this commit describes
can happen, yet the patch carries a Fixes: tag and adds a blocking…
- [Medium] This finding only applies if the commit's premise is true; as
shown in the previous finding, the nf_flowtable core currently…
- [Low] When conn->cnt is set, the reordered release path in
efx_tc_ct_replace() waits for two grace periods back to back.
--
sfc: wait for RCU readers before reclaiming failed CT entries
This patch reorders the error path in efx_tc_ct_replace(). A newly
inserted CT entry is now removed from ct_ht and an RCU grace period is
allowed to elapse before its counter is released and the entry is
freed. The goal is to protect efx_tc_ct_stats() readers that may have
found the entry under RCU.
> diff --git a/drivers/net/ethernet/sfc/tc_conntrack.c b/drivers/net/ethernet/sfc/tc_conntrack.c
> index 77ce2eca43f25..38688ae4e292d 100644
> --- a/drivers/net/ethernet/sfc/tc_conntrack.c
> +++ b/drivers/net/ethernet/sfc/tc_conntrack.c
> @@ -443,11 +443,13 @@ static int efx_tc_ct_replace(struct efx_tc_ct_zone *ct_zone,
> mutex_unlock(&ct_zone->mutex);
> return 0;
> release:
> - if (conn->cnt)
> - efx_tc_flower_release_counter(efx, conn->cnt);
> - if (!old)
> + if (!old) {
> rhashtable_remove_fast(&efx->tc->ct_ht, &conn->linkage,
> efx_tc_ct_ht_params);
> + synchronize_rcu();
> + }
[Severity: Medium]
The commit message says:
efx_tc_ct_stats() may already have found the entry under RCU and
still be using conn->cnt.
Can this happen with the current callers?
efx_tc_flow_block() is only registered through
nf_flow_table_offload_add_cb() in efx_tc_ct_register_zone(). That means
FLOW_CLS_REPLACE, FLOW_CLS_STATS and FLOW_CLS_DESTROY all come from
flow_offload_work_handler(). Each of those work items is allocated by
nf_flow_offload_work_alloc():
net/netfilter/nf_flow_table_offload.c:nf_flow_offload_work_alloc() {
...
if (test_and_set_bit(NF_FLOW_PENDING, &flow->flags))
return NULL;
...
}
flow_offload_work_handler() clears the bit only after the add, del or
stats callback has returned:
smp_mb__before_atomic();
clear_bit(NF_FLOW_PENDING, &offload->flow->flags);
The cookie used as the ct_ht key is set in nf_flow_offload_init():
cls_flow->cookie = (unsigned long)tuple;
This is the address of a tuple inside a single flow. The flow is freed
only after its destroy work has finished, via NF_FLOW_HW_DYING, then
NF_FLOW_HW_DEAD, then flow_offload_del(). nf_flow_table_do_purge() also
runs only after nf_flow_table_offload_flush().
>From that, a FLOW_CLS_STATS for a given cookie does not look like it
can overlap a FLOW_CLS_REPLACE for the same cookie. Is there another
path this commit has in mind? If not, should the change be described as
hardening, without the Fixes: tag?
Separately, some failures used to return without any wait and now
block for a full synchronize_rcu(). These include
efx_tc_ct_parse_match() errors, "NAT only supported for IPv4", CT
labels, and unhandled actions.
This runs on the nf_ft_offload_add workqueue, which all offloading
drivers share. flow_offload_refresh() re-queues a FLOW_CLS_REPLACE
about once per second for any flow that keeps hitting the software
path, and a flow the NIC cannot offload does exactly that. Is the extra
blocking on that shared kworker acceptable for these repeated failures?
[Severity: Medium]
If the premise in the commit message holds, and efx_tc_ct_stats() can
run at the same time as efx_tc_ct_replace() for the same cookie, is
this fix complete?
rhashtable_lookup_get_insert_fast() publishes conn into ct_ht while
conn->cnt is still NULL from kzalloc. conn->cnt is set only after all
match and action parsing, with a plain store:
conn->cnt = cnt;
The reader does this:
drivers/net/ethernet/sfc/tc_conntrack.c:efx_tc_ct_stats() {
...
cnt = conn->cnt;
spin_lock_bh(&cnt->lock);
...
}
There is no NULL check and no READ_ONCE(). A stats lookup anywhere
between the insert and conn->cnt = cnt would dereference a NULL cnt.
That window covers every early error exit, and also successful setups
before the counter exists.
The new synchronize_rcu() only waits for readers once the entry has
been removed. It cannot help a reader that has already loaded a NULL
cnt.
If the race is real, would it be better to insert into ct_ht only after
conn is fully initialized? Another option is for efx_tc_ct_stats() to
tolerate an unfinished entry, using READ_ONCE(conn->cnt) plus a NULL
check, paired with a publishing store on the writer side.
This only matters if the commit's premise holds. As noted above, the
current tree appears to serialize these calls via NF_FLOW_PENDING.
> + if (conn->cnt)
> + efx_tc_flower_release_counter(efx, conn->cnt);
[Severity: Low]
When conn->cnt is set, does this path now wait for two grace periods
back to back? efx_tc_flower_release_counter() already does:
drivers/net/ethernet/sfc/tc_counters.c:efx_tc_flower_release_counter() {
...
synchronize_rcu();
flush_work(&cnt->work);
EFX_WARN_ON_PARANOID(spin_is_locked(&cnt->lock));
kfree(cnt);
}
That grace period starts after conn has been removed from ct_ht. On its
own, it ensures every efx_tc_ct_stats() reader holding conn or
conn->cnt has finished before cnt or conn is freed.
The explicit synchronize_rcu() seems to be needed only when conn->cnt
is NULL. Could it be made conditional on !conn->cnt? Then failures
after the counter is allocated, such as efx_mae_insert_ct() returning
an error when the hardware CT table is full, would wait for one grace
period instead of two.
> kfree(conn);
> return rc;
> }
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179626774776.1539442.17436520173285566977%40jaeyeong.cc
^ permalink raw reply [flat|nested] 3+ messages in thread