* [PATCH net v2 1/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation
2026-06-13 17:42 [PATCH net v2 0/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation Ren Wei
@ 2026-06-13 17:42 ` Ren Wei
2026-06-13 17:42 ` [PATCH net v2 2/2] selftests/tc-testing: act_ct: add TDC test for skb cb preservation across defrag Ren Wei
2026-06-19 0:50 ` [PATCH net v2 0/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Ren Wei @ 2026-06-13 17:42 UTC (permalink / raw)
To: netdev
Cc: jhs, jiri, kuba, paulb, victor, yuantan098, yifanwucs,
tomapufckgml, bird, xizh2024, n05ec
From: Zihan Xi <xizh2024@lzu.edu.cn>
tcf_ct_handle_fragments() calls nf_ct_handle_fragments() without saving
and restoring skb->cb. The defrag helper clears IPCB/IP6CB, which aliases
the tc_skb_cb/qdisc_skb_cb control buffer. Fragmented traffic through
act_ct therefore loses qdisc metadata such as pkt_segs and can trigger
WARN_ON_ONCE() in qdisc_pkt_segs() when panic_on_warn is enabled.
Save and restore the full tc_skb_cb around nf_ct_handle_fragments(),
matching the pattern used by ovs_ct_handle_fragments().
Fixes: ec624fe740b4 ("net/sched: Extend qdisc control block with tc control block")
Cc: stable@vger.kernel.org
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Assisted-by: Codex:gpt-5.4
Signed-off-by: Zihan Xi <xizh2024@lzu.edu.cn>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
---
changes in v2:
- Add TDC selftest in patch 2 per maintainer feedback
- v1 Link: https://lore.kernel.org/all/20260611154939.2615919-1-n05ec@lzu.edu.cn/
net/sched/act_ct.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 6158e13c98d3..ebd40daf05a6 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -845,10 +845,10 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
{
enum ip_conntrack_info ctinfo;
struct nf_conn *ct;
+ struct tc_skb_cb cb;
int err = 0;
bool frag;
u8 proto;
- u16 mru;
/* Previously seen (loopback)? Ignore. */
ct = nf_ct_get(skb, &ctinfo);
@@ -862,12 +862,13 @@ static int tcf_ct_handle_fragments(struct net *net, struct sk_buff *skb,
if (err || !frag)
return err;
- err = nf_ct_handle_fragments(net, skb, zone, family, &proto, &mru);
+ cb = *tc_skb_cb(skb);
+ err = nf_ct_handle_fragments(net, skb, zone, family, &proto, &cb.mru);
if (err)
return err;
*defrag = true;
- tc_skb_cb(skb)->mru = mru;
+ *tc_skb_cb(skb) = cb;
return 0;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH net v2 2/2] selftests/tc-testing: act_ct: add TDC test for skb cb preservation across defrag
2026-06-13 17:42 [PATCH net v2 0/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation Ren Wei
2026-06-13 17:42 ` [PATCH net v2 1/2] " Ren Wei
@ 2026-06-13 17:42 ` Ren Wei
2026-06-19 0:50 ` [PATCH net v2 0/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Ren Wei @ 2026-06-13 17:42 UTC (permalink / raw)
To: netdev, linux-kselftest, linux-kernel
Cc: jhs, jiri, kuba, paulb, victor, yuantan098, yifanwucs,
tomapufckgml, bird, xizh2024, n05ec
From: Zihan Xi <xizh2024@lzu.edu.cn>
Add a tc-testing case that sends IPv4 fragments through act_ct on clsact
egress while a root prio qdisc is present on the transmit path.
The test verifies that packet processing and qdisc accounting continue
to work after conntrack defragmentation, covering tc_skb_cb preservation
across defragmentation.
Signed-off-by: Zihan Xi <xizh2024@lzu.edu.cn>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
---
changes in v2:
- Add tc-testing case 9c2a for skb cb preservation across defrag
- v1 Link: https://lore.kernel.org/all/20260611154939.2615919-1-n05ec@lzu.edu.cn/
.../tc-testing/tc-tests/actions/ct.json | 38 +++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/ct.json b/tools/testing/selftests/tc-testing/tc-tests/actions/ct.json
index 33bb8f3ff8ed..da65f838bd52 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/actions/ct.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/actions/ct.json
@@ -664,5 +664,43 @@
"teardown": [
"$TC qdisc del dev $DEV1 ingress_block 21 clsact"
]
+ },
+ {
+ "id": "9c2a",
+ "name": "Act_ct preserves skb cb across defrag before prio dequeue",
+ "category": [
+ "actions",
+ "ct",
+ "scapy"
+ ],
+ "plugins": {
+ "requires": [
+ "nsPlugin",
+ "scapyPlugin"
+ ]
+ },
+ "setup": [
+ "$TC qdisc add dev $DUMMY root handle 1: prio",
+ "$TC qdisc add dev $DUMMY clsact",
+ "$TC qdisc add dev $DEV1 clsact",
+ "$TC filter add dev $DEV1 ingress protocol ip prio 1 matchall action mirred egress redirect dev $DUMMY"
+ ],
+ "cmdUnderTest": "$TC filter add dev $DUMMY egress protocol ip prio 1 matchall action ct zone 1 pipe",
+ "scapy": [
+ {
+ "iface": "$DEV0",
+ "count": 1,
+ "packet": "[Ether()/frag for frag in fragment(IP(src='10.0.0.10', dst='10.0.0.1', id=1)/UDP(sport=12345, dport=9)/Raw(b'A' * 4000), fragsize=1400)]"
+ }
+ ],
+ "expExitCode": "0",
+ "verifyCmd": "$TC -s qdisc show dev $DUMMY | grep -A 1 '^qdisc prio 1:'",
+ "matchPattern": "Sent [1-9][0-9]* bytes [1-9][0-9]* pkt",
+ "matchCount": "1",
+ "teardown": [
+ "$TC qdisc del dev $DEV1 clsact",
+ "$TC qdisc del dev $DUMMY clsact",
+ "$TC qdisc del dev $DUMMY root handle 1:"
+ ]
}
]
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net v2 0/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation
2026-06-13 17:42 [PATCH net v2 0/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation Ren Wei
2026-06-13 17:42 ` [PATCH net v2 1/2] " Ren Wei
2026-06-13 17:42 ` [PATCH net v2 2/2] selftests/tc-testing: act_ct: add TDC test for skb cb preservation across defrag Ren Wei
@ 2026-06-19 0:50 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-06-19 0:50 UTC (permalink / raw)
To: Ren Wei
Cc: netdev, linux-kselftest, linux-kernel, jhs, jiri, kuba, paulb,
victor, yuantan098, yifanwucs, tomapufckgml, bird, xizh2024
Hello:
This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sun, 14 Jun 2026 01:42:38 +0800 you wrote:
> From: Zihan Xi <xizh2024@lzu.edu.cn>
>
> Hi Linux kernel maintainers,
>
> We found and validated an issue in net/sched/act_ct.c. The bug is
> reachable when configuring TC with act_ct on a netdev (requires
> CAP_NET_ADMIN). We have tested it, and the fix should not affect
> other functionality.
>
> [...]
Here is the summary with links:
- [net,v2,1/2] net/sched: act_ct: preserve tc_skb_cb across defragmentation
https://git.kernel.org/netdev/net/c/9092e15defbe
- [net,v2,2/2] selftests/tc-testing: act_ct: add TDC test for skb cb preservation across defrag
https://git.kernel.org/netdev/net/c/1fd8f80a199d
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] 4+ messages in thread