Thread View: linux.kernel.netdev
8 messages
8 total messages
Started by Jamal Hadi Salim
Mon, 02 Nov 2026 00:37
[PATCH net v2 0/4] net/sched: fix short-skb metadata and namespace boundaries
Author: Jamal Hadi Salim
Date: Mon, 02 Nov 2026 00:37
Date: Mon, 02 Nov 2026 00:37
59 lines
13478 bytes
13478 bytes
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 <shawnq1@163.com> 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 <shawnq1@163.com> with a reproducer, which was verified in our test environment. 3/4: reported by shaos <shawnq1@163.com> 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(-) Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> --- 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.
[PATCH net v2 1/4] net/sched: act_ife: encode configured zero metadata values
Author: Jamal Hadi Salim
Date: Mon, 02 Nov 2026 00:37
Date: Mon, 02 Nov 2026 00:37
82 lines
14105 bytes
14105 bytes
Reported by shaos <shawnq1@163.com> 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).
Fixes: ef6980b6becb ("introduce IFE action")
Fixes: 6a5d58b67e20 ("net sched ife action: add 16 bit helpers")
Reported-by: shaos <shawnq1@163.com>
Link: https://lore.kernel.org/netdev/20261022144739.61342-1-shawnq1@163.com/
Cc: stable@vger.kernel.org
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/act_ife.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 3946a9589bb8..6b23a3965121 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -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);
--
2.43.0
[PATCH net v2 2/4] net/sched: act_ife: require a full Ethernet header on egress
Author: Jamal Hadi Salim
Date: Mon, 02 Nov 2026 00:37
Date: Mon, 02 Nov 2026 00:37
100 lines
15116 bytes
15116 bytes
This 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 <shawnq1@163.com>
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.
Fixes: ef6980b6becb ("introduce IFE action")
Reported-by: Sashiko (nipa) <sashiko-bot@kernel.org>
Reported-by: Sashiko (gemini) <sashiko-bot@kernel.org>
Reported-by: shaos <shawnq1@163.com>
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260821164031.32824-1-victor%40mojatatu.com
Link: https://sashiko.dev/#/patchset/20260821164031.32824-1-victor@mojatatu.com
Link: https://lore.kernel.org/netdev/20261022144736.61227-1-shawnq1@163.com/
Cc: stable@vger.kernel.org
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
net/sched/act_ife.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/sched/act_ife.c b/net/sched/act_ife.c
index 6b23a3965121..5a527da00566 100644
--- a/net/sched/act_ife.c
+++ b/net/sched/act_ife.c
@@ -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,
--
2.43.0
[PATCH net v2 3/4] net/sched: sch_teql: reject qdiscs from another network namespace
Author: Jamal Hadi Salim
Date: Mon, 02 Nov 2026 00:37
Date: Mon, 02 Nov 2026 00:37
88 lines
14246 bytes
14246 bytes
Reported by shaos <shawnq1@163.com> 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.
Fixes: 7316ae88c43d ("net_sched: make traffic control network namespace aware")
Reported-by: shaos <shawnq1@163.com>
Link: https://lore.kernel.org/netdev/20261022144830.67948-1-shawnq1@163.com/
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v1.r2.20261031160050-3%40mojatatu.com
Cc: stable@vger.kernel.org
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
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(-)
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
index 70c948a26f80..dc21cd9704a2 100644
--- a/net/sched/sch_teql.c
+++ b/net/sched/sch_teql.c
@@ -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));
--
2.43.0
[PATCH net v2 4/4] selftests: tc-testing: teql: reject attach from another netns
Author: Jamal Hadi Salim
Date: Mon, 02 Nov 2026 00:37
Date: Mon, 02 Nov 2026 00:37
64 lines
12848 bytes
12848 bytes
Found 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.
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
.../tc-testing/tc-tests/qdiscs/teql.json | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json
index 0179c57104ad..3df315629d2f 100644
--- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json
+++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json
@@ -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
+ ]
+ ]
}
]
--
2.43.0
Re: [PATCH net v2 3/4] net/sched: sch_teql: reject qdiscs from another network namespace
Author: netdev-bot+sashiko
Date: Tue, 03 Nov 2026 00:40
Date: Tue, 03 Nov 2026 00:40
142 lines
13143 bytes
13143 bytes
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.
Link: https://lore.kernel.org/netdev/20261022144830.67948-1-shawnq1@163.com/
Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v1.r2.20261031160050-3%40mojatatu.com
> diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
> index 70c948a26f809..dc21cd9704a25 100644
> --- a/net/sched/sch_teql.c
> +++ b/net/sched/sch_teql.c
[ ... ]
> @@ -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.
>
> - 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
Re: [PATCH net v2 4/4] selftests: tc-testing: teql: reject attach from another netns
Author: netdev-bot+sashiko
Date: Tue, 03 Nov 2026 00:40
Date: Tue, 03 Nov 2026 00:40
99 lines
11372 bytes
11372 bytes
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.
> diff --git a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json
> index 0179c57104adb..3df315629d2fc 100644
> --- a/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json
> +++ b/tools/testing/selftests/tc-testing/tc-tests/qdiscs/teql.json
> @@ -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",
[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.
> + "verifyCmd": "$TC qdisc show dev $DUMMY",
> + "matchPattern": "qdisc teql0 3: root",
> + "matchCount": "0",
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v2.r0.20261101171325%40mojatatu.com
Re: [PATCH net v2 3/4] net/sched: sch_teql: reject qdiscs from another network namespace
Author: Jamal Hadi Salim
Date: Tue, 03 Nov 2026 11:04
Date: Tue, 03 Nov 2026 11:04
163 lines
17815 bytes
17815 bytes
On Mon, Nov 2, 2026 at 7:40 PM <netdev-bot+sashiko@kernel.org> wrote:
>
> 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.
Nothing to do with this patch - preexisting. Captured for a followup.
> - [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
> --
>
> 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.
>
> Link: https://lore.kernel.org/netdev/20261022144830.67948-1-shawnq1@163.com/
> Link: https://netdev-ai.bots.linux.dev/sashiko/#/patchset/SER-NSBD.v1.r2.20261031160050-3%40mojatatu.com
>
> > diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c
> > index 70c948a26f809..dc21cd9704a25 100644
> > --- a/net/sched/sch_teql.c
> > +++ b/net/sched/sch_teql.c
>
> [ ... ]
>
> > @@ -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.
>
> >
> > - 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads