Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/tc-testing: Add a test for HFSC eltree double add with reentrant enqueue behaviour on netem

Reproduce the UAF scenario where netem is a child of HFSC and HFSC
is configured to use the eltree. In such case, this TDC test would
cause the HFSC class to be added to the eltree twice resulting
in a UAF.

Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Link: https://patch.msgid.link/20250522181448.1439717-3-pctammela@mojatatu.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Pedro Tammela and committed by
Paolo Abeni
2945ff73 ac9fe7dd

+35
+35
tools/testing/selftests/tc-testing/tc-tests/infra/qdiscs.json
··· 600 600 "matchPattern": "qdisc hfsc", 601 601 "matchCount": "1", 602 602 "teardown": ["$TC qdisc del dev $DEV1 root handle 1: drr"] 603 + }, 604 + { 605 + "id": "309e", 606 + "name": "Test HFSC eltree double add with reentrant enqueue behaviour on netem", 607 + "category": [ 608 + "qdisc", 609 + "hfsc" 610 + ], 611 + "plugins": { 612 + "requires": "nsPlugin" 613 + }, 614 + "setup": [ 615 + "$IP link set dev $DUMMY up || true", 616 + "$IP addr add 10.10.11.10/24 dev $DUMMY || true", 617 + "$TC qdisc add dev $DUMMY root handle 1: tbf rate 8bit burst 100b latency 1s", 618 + "$TC qdisc add dev $DUMMY parent 1:0 handle 2:0 hfsc", 619 + "ping -I $DUMMY -f -c10 -s48 -W0.001 10.10.11.1 || true", 620 + "$TC class add dev $DUMMY parent 2:0 classid 2:1 hfsc rt m2 20Kbit", 621 + "$TC qdisc add dev $DUMMY parent 2:1 handle 3:0 netem duplicate 100%", 622 + "$TC class add dev $DUMMY parent 2:0 classid 2:2 hfsc rt m2 20Kbit", 623 + "$TC filter add dev $DUMMY parent 2:0 protocol ip prio 1 u32 match ip dst 10.10.11.2/32 flowid 2:1", 624 + "$TC filter add dev $DUMMY parent 2:0 protocol ip prio 2 u32 match ip dst 10.10.11.3/32 flowid 2:2", 625 + "ping -c 1 10.10.11.2 -I$DUMMY > /dev/null || true", 626 + "$TC filter del dev $DUMMY parent 2:0 protocol ip prio 1", 627 + "$TC class del dev $DUMMY classid 2:1", 628 + "ping -c 1 10.10.11.3 -I$DUMMY > /dev/null || true" 629 + ], 630 + "cmdUnderTest": "$TC class change dev $DUMMY parent 2:0 classid 2:2 hfsc sc m2 20Kbit", 631 + "expExitCode": "0", 632 + "verifyCmd": "$TC -j class ls dev $DUMMY classid 2:1", 633 + "matchJSON": [], 634 + "teardown": [ 635 + "$TC qdisc del dev $DUMMY handle 1:0 root", 636 + "$IP addr del 10.10.10.10/24 dev $DUMMY || true" 637 + ] 603 638 } 604 639 ]