net/sched: fix short-skb metadata and namespace boundaries
Subsystems (5)
Jamal Hadi Salim
maintainerv2 cover net/sched: fix short-skb metadata and namespace boundaries
This series fixes three independent boundary problems in net/sched, and adds a tc-testing case for the third.
1/4 act_ife: encode a configured zero metadata value. The u32 and u16 presence callbacks reserve an 8-byte TLV for a configured zero value, but the encoders returned without writing it, leaking stale skb headroom bytes.
2/4 act_ife: require a full Ethernet header on egress. An undersized linear head can make the encoder read past the end of the skb data.
3/4 sch_teql: reject qdiscs from another network namespace. The global TEQL master lives in the initial netns; a qdisc created in another netns could still mutate the master's MTU and flags.
4/4 selftests: tc-testing: cover the cross-netns attach rejection. The existing 124e case attaches a child qdisc from nsPlugin's namespace, so it is answered by whichever of the two rejection checks runs first. This case attaches a root qdisc, so only the namespace check can refuse it.
Origins:
1/4: reported by shaos <[email protected]> with a reproducer, which was reproduced and verified in our test environment.
2/4: found by Sashiko (nipa and gemini) while reviewing Victor Nogueira's parent act_ife patchset; independently reported by shaos <[email protected]> with a reproducer, which was verified in our test environment.
3/4: reported by shaos <[email protected]> with a reproducer, which was reproduced and verified in our test environment.
4/4: follows a Sashiko (nipa) review of the repost2 posting of 3/4, which pointed out that the new check masks what 124e asserts.
The four patches are independent. They target net and the three fixes carry a stable nomination; the test case does not. They are sent together because they share the short-skb and namespace-boundary review context.
Jamal Hadi Salim (4):
net/sched: act_ife: encode configured zero metadata values net/sched: act_ife: require a full Ethernet header on egress net/sched: sch_teql: reject qdiscs from another network namespace
selftests: tc-testing: teql: reject attach from another netns
net/sched/act_ife.c | 13 ++++++----- net/sched/sch_teql.c | 9 ++++++-- .../selftests/tc-testing/tc-tests/qdiscs/teql.json | 27 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 8 deletions(-)
---
v2: considers comments from Sashiko (nipa) on the repost2 posting. The cross-netns check in 3/4 ran before the "teql can only be used as root" check, so every case it did not catch was answered by that check, masking the assertion that tc-testing case 124e makes. The root-parent validation now runs first and the namespace check second, and 4/4 covers the namespace rejection on its own as suggested by sashiko-nipa.
1/4 and 2/4 are unchanged from the repost2 posting.
Jamal Hadi Salim
maintainerPATCH v2 1/4 net/sched: act_ife: encode configured zero metadata values
Reported by shaos <[email protected]> with a reproducer for the 32-bit case, which was reproduced and verified in our test environment.
The issue:ife_check_meta_u32() and ife_check_meta_u16() both reserve eight bytes of metadata for a configured value even when that value is zero, but the matching encoder returns without calling ife_tlv_meta_encode(). The encoder therefore writes neither the TLV header nor its value, while the enclosing IFE length still includes the reserved bytes, exposing stale skb headroom contents to the peer.
The 32-bit helper has been present since the IFE action was introduced (v4.6); the 16-bit helper was added with the 16-bit metadata helpers used by the skbtcindex callback (v4.9). Both defects predate the oldest supported stable kernel (5.10), so they are fixed together in this patch. Each hunk keeps its own Fixes: tag for provenance.
The fix:
Encode any configured value, including zero; skip the TLV only when there is neither a configured nor a runtime value. The runtime fallback is unchanged.
A raw TCA_IFE_METALST netlink request is needed to express the configured zero: the IFE_META_SKBMARK attribute carries four zero payload bytes for the u32 helper, and IFE_META_TCINDEX two zero payload bytes for the 16-bit helper (not an absent or zero-length attribute). Stock tc cannot build these requests; "use mark 0x0" emits no mark attribute and "allow mark" emits a zero-length one.
Conditions to recreate the bug:CONFIG_NET_ACT_IFE=y, CONFIG_NET_IFE_SKBMARK=y, CONFIG_NET_IFE_SKBTCINDEX=y, CONFIG_NET_CLS_MATCHALL=y, CONFIG_NET_SCH_INGRESS=y, CONFIG_USER_NS=y, CONFIG_NET_NS=y, CONFIG_VETH=y. In a fresh user and network namespace create a veth pair and attach clsact to the egress side. Install a matchall filter whose ife encode action carries a zero skb mark (or a zero tcindex) in TCA_IFE_METALST. Send a frame through the veth and inspect the IFE metadata in the received frame. The metadata region is eight bytes but holds neither a valid TLV header nor a value; it exposes prior headroom contents. Setting the value to a nonzero one does not trigger the leak. The namespace needs CAP_NET_ADMIN; no additional privilege is required. With the fix the zero TLVs are 0001000800000000 (u32) and 0005000600000000 (u16).
---
net/sched/act_ife.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
net/sched/act_ife.c +2 -4
@@ -50,8 +50,7 @@ int ife_encode_meta_u16(u16 metaval, void *skbdata, struct tcf_meta_info *mi) edata = *(u16 *)mi->metaval; else if (metaval) edata = metaval; - -if (!edata)/* will not encode */ + else return 0; edata =htons (edata);
@@ -94,8 +93,7 @@ int ife_encode_meta_u32(u32 metaval, void *skbdata, struct tcf_meta_info *mi) edata = *(u32 *)mi->metaval; else if (metaval) edata = metaval; - -if (!edata)/* will not encode */ + else return 0; edata =htonl (edata);
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 2/4 net/sched: act_ife: require a full Ethernet header on egress
In reply to Jamal Hadi SalimThis is a followup of commit 5b483f7791b0 ("net/sched: act_ife: Only operate on Ethernet frames") as reported by Sashiko.
The finding was raised by both Sashiko providers (nipa and gemini) while reviewing the parent patchset. shaos <[email protected]> independently reported the same undersized-egress path with a reproducer, which was reproduced and verified in our test environment.
The issue:
On egress tcf_ife_is_eth_skb() only checks the device type; it does not check that the skb carries a full Ethernet header. For an Ethernet or loopback device it returns true even when the skb has no Ethernet header. tcf_ife_encode() then calls ife_encode(), which copies ETH_HLEN bytes from skb->data. A short skb therefore reads past its linear data and the copied bytes, including stale kernel memory, are emitted in the outer Ethernet header.
The parent commit fixed the reported ingress mac_len case but left the egress path without a length check.
A total-length test is not sufficient: a non-GSO TUN skb can have a large total length while only a single byte sits in the linear area, so ife_encode() still reads past the linear header. Require instead that the Ethernet header the encoder copies is present in the linear part of the skb.
The Fix:
On egress require pskb_may_pull(skb, ETH_HLEN) before encoding, which ensures the Ethernet header is present in the linear data ife_encode() copies from; the ingress mac_len check is unchanged. A short egress skb is now dropped instead of being encoded.
Conditions to recreate the bug:CONFIG_NET_ACT_IFE=y, CONFIG_NET_CLS_MATCHALL=y, CONFIG_NET_SCH_INGRESS=y, CONFIG_TUN=y, CONFIG_NET_ACT_MIRRED=y. In two user and network namespaces (a victim and an attacker), open a TUN device in IFF_TUN mode and attach clsact to it and to lo. Redirect ingress traffic from the TUN device to lo egress with mirred, and install an ife encode action on lo egress:
tc qdisc add dev <tun> clsact
tc qdisc add dev lo clsact
tc filter add dev <tun> ingress matchall action mirred egress \
redirect dev lo
tc filter add dev lo egress matchall action ife encode use mark 1 \
action ok
Send a TUN packet shorter than ETH_HLEN (a one-byte payload is enough) and receive the emitted frame on the other side. Without the fix the outer Ethernet header contains bytes copied past the short packet; with the fix the short skb is dropped. The attacker needs CAP_NET_ADMIN in its user namespace; no init-net privilege is required.
The same path is reachable when the total length is large but the Ethernet header is not linear: write a non-GSO virtio header with hdr_len=1 followed by an 8192-byte packet so that only one byte stays linear. Without the fix the copied header reads past the linear data; with the fix the header is pulled into the linear area before the copy.
---
net/sched/act_ife.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/sched/act_ife.c +5 -2
@@ -878,13 +878,16 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,* is an Ethernet header because the skb could've been redirected with mirred * from a non-Ethernet device. */ -static bool tcf_ife_is_eth_skb (const struct sk_buff *skb) +static bool tcf_ife_is_eth_skb (struct sk_buff *skb) {if (skb->dev->type !=ARPHRD_ETHER && skb->dev->type !=ARPHRD_LOOPBACK )return false; -return !skb_at_tc_ingress (skb) || skb->mac_len ==ETH_HLEN ; +if (skb_at_tc_ingress (skb)) +return skb->mac_len ==ETH_HLEN ; + +return pskb_may_pull (skb,ETH_HLEN ); } TC_INDIRECT_SCOPE int tcf_ife_act(struct sk_buff *skb,
Signature · 1 line
2.43.0
Jamal Hadi Salim
maintainerPATCH v2 3/4 net/sched: sch_teql: reject qdiscs from another network namespace
In reply to Jamal Hadi SalimReported by shaos <[email protected]> with a reproducer, which was reproduced and verified in our test environment.
The issue:
The teql master devices are created once in the initial network namespace and their Qdisc_ops are global. teql_qdisc_init() takes the teql_master embedded in the registered sch->ops and uses it without checking whether the new qdisc's device lives in the same network namespace as the master. A qdisc created in another netns can therefore attach to the init-net master and change its MTU and flags.
The Fix:
Reject a teql qdisc whose device is not in the master's network namespace with -EOPNOTSUPP and an extack message; same-netns teql still works.
Initialize the private skb queue before any validation so every constructor failure path, including qdisc_create_dflt(), which resets the qdisc before destroying it, sees an initialized empty queue.
Conditions to recreate the bug:CONFIG_NET_SCH_TEQL=y, CONFIG_DUMMY=y, CONFIG_USER_NS=y, CONFIG_NET_NS=y. As an unprivileged UID, unshare a user and network namespace, create a dummy device, set its MTU to 60000, and add a root teql0 qdisc:
unshare -Urn
ip link add dummy0 type dummy
ip link set dummy0 mtu 60000
tc qdisc add dev dummy0 root teql0
The init-net teql0 device changes from MTU 1500 to 60000. A pfifo control on the same device leaves the MTU unchanged, and a direct MTU change on init-net teql0 is denied. The namespace needs CAP_NET_ADMIN; no init-net privilege is required. With the fix the attach fails with "Operation not supported" and the init-net MTU stays 1500.
---
v2: considers comments from Sashiko (nipa) on the repost2 posting:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v1.r2.20261031160050-3%40mojatatu.com
The cross-netns check ran before the "teql can only be used as root" check, so every case it did not catch was answered by that check, masking the assertion that tc-testing case 124e makes. The root-parent validation now runs first and the namespace check second; 4/4 adds a case that covers the namespace rejection on its own.
net/sched/sch_teql.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/sched/sch_teql.c +7 -2
@@ -200,6 +200,8 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,struct Qdisc *first;unsigned long flags; +skb_queue_head_init (&q->q); +if (dev->hard_header_len > m->dev->hard_header_len)return -EINVAL ;
@@ -211,9 +213,12 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,return -EOPNOTSUPP ; } - q->m = m; +if (dev_net (dev) !=dev_net (m->dev)) { +NL_SET_ERR_MSG_MOD (extack,"teql master is in a different network namespace" ); +return -EOPNOTSUPP ; + } -skb_queue_head_init (&q->q); + q->m = m;raw_spin_lock_irqsave (&m->slaves_lock, flags); first =rcu_dereference_protected (m->slaves,lockdep_is_held (&m->slaves_lock));
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net v2 3/4] net/sched: sch_teql: reject qdiscs from another network namespace
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · 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] The fix only enforces the master/slave same-netns rule once, when a slave attaches.
- [Low] After this patch, tc-testing case 124e ("Try to add teql as a child qdisc", tools/testing/selftests/tc-testing/tc-…
--
net/sched: sch_teql: reject qdiscs from another network namespace
With this patch, teql_qdisc_init() rejects a teql slave qdisc whose device is in a different network namespace from the teql master. It returns -EOPNOTSUPP and sets an extack message. It also moves skb_queue_head_init() ahead of all validation, so every constructor failure path sees an initialized queue.
Quoted 4 lines
net/sched/sch_teql.c +0
-0
[ ... ]
net/sched/sch_teql.c static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt, · line 219
Quoted 9 lines
net/sched/sch_teql.c +4
-1@@ -211,9 +213,12 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,return -EOPNOTSUPP ; } - q->m = m; +if (dev_net (dev) !=dev_net (m->dev)) { +NL_SET_ERR_MSG_MOD (extack,"teql master is in a different network namespace" ); +return -EOPNOTSUPP ; + }
[Severity: Medium]
This checks the namespace only once, when the slave attaches. What keeps the master and its slaves in the same namespace after that?
teql_master_setup() does not set dev->netns_immutable, and sch_teql does not register a netdevice notifier. So the master can still be moved with "ip link set teql0 netns X". __dev_change_net_namespace() only refuses the move when netns_immutable is set, and it only shuts down the device being moved:
net/core/dev.c:__dev_change_net_namespace() {
...
if (dev->netns_immutable) {
NL_SET_ERR_MSG(extack, "The interface netns is immutable");
goto out;
}
...
dev_shutdown(dev);
...
}The slave qdiscs sit on other net_devices, so teql_destroy() never runs for them. m->slaves and NEXT_SLAVE() still point at devices in the old namespace.
After the move, teql_master_open() takes its MTU and flags from those slaves and teql_master_mtu() checks against them. teql_master_xmit() also sends the master's traffic through them:
teql_master_xmit()
struct net_device *slave = qdisc_dev(q);
...Doesn't that bring back the cross-netns master/slave state this patch is trying to remove?
There is also a way back into init_net. teql0 has no rtnl_link_ops, so when its netns is destroyed, default_device_exit_net() moves it back to init_net:
err = dev_change_net_namespace(dev, &init_net, fb_name);
Suppose root gives teql0 to a container netns B. The container could attach a slave in B, move teql0 to another netns C that it owns, and then delete C. teql0 would end up in init_net with a slave on a container-controlled device in B. That looks like the case the commit message describes.
The first move out of init_net needs CAP_NET_ADMIN in init_net, so this patch does close the unprivileged reproducer in the commit message.
Could teql_master_setup() also set dev->netns_immutable = true? Another option would be to detach the slaves when the master changes netns.
[Severity: Low]
After this change, does tc-testing case 124e ("Try to add teql as a child qdisc") still test the root-only rule?
124e requires nsPlugin, so $DUMMY is created inside a per-test netns. teql0 is always in init_net. The root-only check and the new netns check both return -EOPNOTSUPP. 124e only checks the exit code and an empty matchJSON:
"cmdUnderTest": "$TC qdisc add dev $DUMMY parent 1:1 handle 2:1 teql0", "expExitCode": "2",
"verifyCmd": "$TC -s -j qdisc ls dev $DUMMY parent 1:1", "matchJSON": [],
If the "teql can only be used as root" check were removed or broken, the netns check would still reject the command with the same exit code. The test would still pass.
The v2 notes say:
The cross-netns check ran before the "teql can only be used as root" check, so every case it did not catch was answered by that check, masking the assertion that tc-testing case 124e makes. The root-parent validation now runs first and the namespace check second
The new order only changes which check fires first. Either way, 124e cannot tell the two checks apart.
Could 124e run in init_net instead? It could drop nsPlugin and create $DUMMY in its setup, as 84a0 does. Alternatively, it could check the extack message.
Quoted 6 lines
net/sched/sch_teql.c +1
-1-skb_queue_head_init (&q->q); + q->m = m;raw_spin_lock_irqsave (&m->slaves_lock, flags); first =rcu_dereference_protected (m->slaves,lockdep_is_held (&m->slaves_lock));
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v2.r0.20261101171325%40mojatatu.com
Jamal Hadi Salim
maintainerRe: [PATCH net v2 3/4] net/sched: sch_teql: reject qdiscs from another network namespace
Quoted 6 lines · On Mon, Nov 2, 2026 at 7:40 PM <[email protected]> wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
Quoted 8 lines
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] The fix only enforces the master/slave same-netns rule once, when a slave attaches.
Nothing to do with this patch - preexisting. Captured for a followup.
Quoted 2 lines
- [Low] After this patch, tc-testing case 124e ("Try to add teql as a child qdisc", tools/testing/selftests/tc-testing/tc-…
True - 124e is now answered by either check, so it no longer isolates the root-only rule. I will send v3.
pw-bot: cr
Quoted 125 lines
--
net/sched:
sch_teql: reject qdiscs from another network namespaceWith this patch,
teql_qdisc_init()rejects a teql slave qdisc whose device is in a different network namespace from the teql master. It returns-EOPNOTSUPPand sets an extack message. It also movesskb_queue_head_init()ahead of all validation, so every constructor failure path sees an initialized queue.Quoted 4 lines
net/sched/sch_teql.c +0
-0[ ... ]
net/sched/sch_teql.c static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt, · line 219
Quoted 9 lines
net/sched/sch_teql.c +4
-1@@ -211,9 +213,12 @@ static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt,return -EOPNOTSUPP ; } - q->m = m; +if (dev_net (dev) !=dev_net (m->dev)) { +NL_SET_ERR_MSG_MOD (extack,"teql master is in a different network namespace" ); +return -EOPNOTSUPP ; + }[Severity: Medium]
This checks the namespace only once, when the slave attaches. What keeps the master and its slaves in the same namespace after that?
teql_master_setup()does not setdev->netns_immutable, andsch_teqldoes not register a netdevice notifier. So the master can still be moved with "ip link set teql0 netns X".__dev_change_net_namespace()only refuses the move whennetns_immutableis set, and it only shuts down the device being moved:net/core/dev.c:__dev_change_net_namespace() { ... if (dev->netns_immutable) { NL_SET_ERR_MSG(extack, "The interface netns is immutable"); goto out; } ... dev_shutdown(dev); ... }The slave qdiscs sit on other
net_devices, soteql_destroy()never runs for them.m->slavesandNEXT_SLAVE()still point at devices in the old namespace.After the move,
teql_master_open()takes its MTU and flags from those slaves andteql_master_mtu()checks against them.teql_master_xmit()also sends the master's traffic through them:
teql_master_xmit()struct net_device *slave = qdisc_dev(q); ...Doesn't that bring back the cross-netns master/slave state this patch is trying to remove?
There is also a way back into
init_net. teql0 has nortnl_link_ops, so when its netns is destroyed,default_device_exit_net()moves it back toinit_net:err = dev_change_net_namespace(dev, &init_net, fb_name);Suppose root gives teql0 to a container netns B. The container could attach a slave in B, move teql0 to another netns C that it owns, and then delete C. teql0 would end up in
init_netwith a slave on a container-controlled device in B. That looks like the case the commit message describes.The first move out of
init_netneedsCAP_NET_ADMINininit_net, so this patch does close the unprivileged reproducer in the commit message.Could
teql_master_setup()also setdev->netns_immutable= true? Another option would be to detach the slaves when the master changes netns.[Severity: Low]
After this change, does tc-testing case 124e ("Try to add teql as a child qdisc") still test the root-only rule?124e requires nsPlugin, so $DUMMY is created inside a per-test netns. teql0 is always in
init_net. The root-only check and the new netns check both return-EOPNOTSUPP. 124e only checks the exit code and an empty matchJSON:"cmdUnderTest": "$TC qdisc add dev $DUMMY parent 1:1 handle 2:1 teql0", "expExitCode": "2",
"verifyCmd": "$TC -s -j qdisc ls dev $DUMMY parent 1:1", "matchJSON": [],If the "teql can only be used as root" check were removed or broken, the netns check would still reject the command with the same exit code. The test would still pass.
The v2 notes say:
The cross-netns check ran before the "teql can only be used as root" check, so every case it did not catch was answered by that check, masking the assertion that tc-testing case 124e makes. The root-parent validation now runs first and the namespace check second
The new order only changes which check fires first. Either way, 124e cannot tell the two checks apart.
Could 124e run in
init_netinstead? It could drop nsPlugin and create $DUMMY in its setup, as 84a0 does. Alternatively, it could check the extack message.net/sched/sch_teql.c static int teql_qdisc_init(struct Qdisc *sch, struct nlattr *opt, · line 224
Quoted 6 lines
net/sched/sch_teql.c +1
-1-skb_queue_head_init (&q->q); + q->m = m;raw_spin_lock_irqsave (&m->slaves_lock, flags); first =rcu_dereference_protected (m->slaves,lockdep_is_held (&m->slaves_lock));--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v2.r0.20261101171325%40mojatatu.com
Jamal Hadi Salim
maintainerPATCH v2 4/4 selftests: tc-testing: teql: reject attach from another netns
In reply to Jamal Hadi SalimFound by Sashiko (nipa) while reviewing the previous posting of the cross-netns rejection fix:
https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v1.r2.20261031160050-3%40mojatatu.com
The issue:
Case 124e covers the root-only rejection, but nsPlugin moves the test device into its own network namespace, so the namespace check answers it first unless the two checks run in the other order. Nothing else covers the namespace rejection: the teql0 master is registered in init_net, and a root qdisc attach from the test namespace must be refused with -EOPNOTSUPP. Without a case of its own, a later reordering can make the namespace check answer 124e and leave the root check untested.
The Fix:
Add a case that attaches a root teql0 qdisc from the test namespace. The attach is a root qdisc as well, so only the namespace check can refuse it. Without the fix the attach succeeds and the master is mutated from the foreign namespace.
--- .../tc-testing/tc-tests/qdiscs/teql.json | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+)
tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json +27 -0
@@ -106,5 +106,32 @@ "teardown": [ "$TC qdisc del dev $DUMMY root handle 1:" ] + }, + { + "id": "6a06", + "name": "Reject TEQL attach from a different network namespace", + "category": [ + "qdisc", + "teql" + ], + "plugins": { + "requires": [ + "nsPlugin" + ] + }, + "setup": [], + "cmdUnderTest": "$TC qdisc add dev $DUMMY root handle 3: teql0", + "expExitCode": "2", + "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "qdisc teql0 3: root", + "matchCount": "0", + "teardown": [ + [ + "$TC qdisc del dev $DUMMY root handle 3:", + 0, + 1, + 2 + ] + ] } ]
Signature · 1 line
2.43.0
[email protected]
AI reviewRe: [PATCH net v2 4/4] selftests: tc-testing: teql: reject attach from another netns
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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] Test 124e ("Try to add teql as a child qdisc", tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json) no…
--
selftests: tc-testing: teql: reject attach from another netns
This commit adds tdc case 6a06 to teql.json. The case attaches a root teql0 qdisc from the nsPlugin test namespace and expects the attach to be refused, because the teql0 master is registered in init_net.
Quoted 14 lines
tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json +6
-0@@ -106,5 +106,32 @@ "teardown": [ "$TC qdisc del dev $DUMMY root handle 1:" ] + }, + { + "id": "6a06", + "name": "Reject TEQL attach from a different network namespace", + "category": [ + "qdisc",
tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json line 124
Quoted 10 lines
tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json +10
-0+ "teql" + ], + "plugins": { + "requires": [ + "nsPlugin" + ] + }, + "setup": [], + "cmdUnderTest": "$TC qdisc add dev $DUMMY root handle 3: teql0", + "expExitCode": "2",
[Severity: Medium]
This case isolates the namespace check. Is the root-only check in teql_qdisc_init() still tested on its own anywhere?
The commit message says:
Without a case of its own, a later reordering can make the namespace check answer 124e and leave the root check untested.
Case 124e ("Try to add teql as a child qdisc") also requires nsPlugin. _ipr2_ns_create_cmds() in nsPlugin.py moves $DUMMY into the test netns:
cmds.append(self._replace_keywords('link set $DUMMY netns {}'.format(ns)))
So the child attach in 124e:
"cmdUnderTest": "$TC qdisc add dev $DUMMY parent 1:1 handle 2:1 teql0", "expExitCode": "2",
fails both of these checks in net/sched/sch_teql.c:teql_qdisc_init(), and both return the same errno:
if (sch->parent != TC_H_ROOT) {
NL_SET_ERR_MSG_MOD(extack, "teql can only be used as root");
return -EOPNOTSUPP;
}
if (dev_net(dev) != dev_net(m->dev)) {
NL_SET_ERR_MSG_MOD(extack, "teql master is in a different network namespace");
return -EOPNOTSUPP;
}If the sch->parent != TC_H_ROOT check were removed or broken, the netns check would still refuse 124e's attach. tc would still exit 2, matchJSON would still be empty, and 124e would still pass.
After this patch, does any case in teql.json fail if the root-only check is removed?
One option is a child-attach case that does not use nsPlugin and creates $DUMMY in init_net, the way 84a0 and 7734 do. Then only the root check could refuse the attach.
Quoted 3 lines
tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json +3
-0+ "verifyCmd": "$TC qdisc show dev $DUMMY", + "matchPattern": "qdisc teql0 3: root", + "matchCount": "0",
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v2.r0.20261101171325%40mojatatu.com