CVE-2026-99638: net/sched: clamp skb->queue_mapping before indexing the tx queue
In the Linux kernel, the following vulnerability has been resolved:
net/sched: clamp skb->queuemapping before indexing the tx queue
This issue was caught by Sashiko (nipa). A producer-side path cap is already merged (ea4d4b5dddb5); this patch adds the matching consumer-side caps.
The issue: The tx queue is picked and capped in netdevcorepicktx() before the devxmitskb() qdisc enqueue path. A tc BPF program running inside an egress qdisc (not clsact) can then change skbuff->queuemapping; that store is never re-checked. bpfconvertctxaccess() bounds it only by NOQUEUEMAPPING, not by the device's queue count.
Two consumers read the stale value:
- On dequeue, qdiscrestart() calls netdevgettxqueue(), which indexes dev->tx[]. netdevgettxqueue() guards it with just a DEBUGNETWARNONONCE, so schdirectxmit() takes the out-of-bounds txq->xmitlock and writes txq->xmitlockowner past the end of the allocation on non-lltx devices such as ifb. Drivers that index their rings from skbgetqueuemapping() (ex: ifb) go out of range the same way.
- On enqueue, taprioenqueue() indexes q->qdiscs[] with the same value; the array is sized dev->numtxqueues. A duplicating netem on a child qdisc clones the skb and re-enqueues the clone at the taprio root (qdiscrootbh()) through a direct rootq->enqueue() call, so the value reaches taprioenqueue() before any dequeue cap runs.
The Fix: Cap the mapping at the consumers and write the capped value back, so the qdisc's tx[] lookup, the taprio q->qdiscs[] lookup and any later driver read stay in range.
On the dequeue side the cap folds into the dequeue path instead of a separate walk over the returned list: dequeueskb() caps the head, and each bulk helper caps the element it appends. For a qdisc that is not TCQFONETXQUEUE, netdevcaptxqueue() logs a ratelimited notice and selects queue 0.
A TCQFONETXQUEUE qdisc is bound to a single tx queue: dequeueskb() uses q->devqueue for the frozen check, the BQL limit and the trace point, while qdiscrestart() transmits on the skb's queue. Capping an out-of-range mapping to queue 0 would therefore send a per-queue child's skb through a different queue than the one it was dequeued for. On mq, mqprio, taprio and htb offload children, a stopped queue 0 could then park the list in q->gsoskb, and the later wake would schedule queue 0's own child instead of this qdisc. Pin a TCQFONETXQUEUE mapping to the qdisc's own queue to keep the documented invariant.
The pin covers every mapping, not only an out-of-range one: an in-range mapping that a filter sets on one of those per-queue children is rewritten to the child's own queue, and this path does not call netdevcaptxqueue(), so it logs no notice. On a single-queue device qdisccreate() sets TCQFONETXQUEUE, so the one-queue trigger described below also takes this branch and is corrected without a notice.
That also keeps a bulk list on one queue by construction: every element of a TCQFONETXQUEUE qdisc, including a follower changed by a filter, is pinned to q->devqueue before it is appended. The fast bulk helper therefore needs no head comparison and no skbbadtxq requeue; the slow helper, used only by non-ONETXQUEUE qdiscs, still compares and requeues a mismatched follower, where a wake on any queue reschedules q.
On the enqueue side taprioenqueue() caps the mapping against realnumtxqueues and writes it back before selecting q->qdiscs[queue], so a duplicating child cannot steer the clone out of the array.
Conditions to recreate the bug: The dequeue path: load a SCHEDCLS or SCHEDACT program that stores skbuff->queuemapping (a tc BPF action is enough), attach it to a transmit qdisc (for example a matchall filter on a prio root), and send a packet. With a 1-queue device a store of 1 indexes one past dev->tx[]. Under KASAN with paniconwarn=1 the unfixed kernel faults with "BUG: KASAN: slab-out- ---truncated---
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.12.118 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 6.18.64 - Upgrade
Upgrade
linux/Kernelto a version that resolves this vulnerability.Fixed in 7.3.5 - Compensating control
Clamp skb->queue_mapping at the consumer paths and write the capped value back before indexing queues: cap the mapping in taprio_enqueue() against real_num_tx_queues, cap the head in dequeue_skb(), and cap each element appended by bulk helpers. For TCQ_F_ONETXQUEUE qdiscs, pin every mapping to the qdisc’s own queue.
Frequently Asked Questions
Which systems are exposed to this issue?
Systems are exposed when a tc BPF program runs inside an egress qdisc other than clsact and can modify __sk_buff->queue_mapping after transmit-queue selection. The affected consumers include qdisc dequeue processing and drivers that derive ring selection from skb_get_queue_mapping(), with non-lltx devices such as ifb specifically noted.
Does exploitation depend on using the taprio qdisc?
No. taprio is one affected enqueue-side consumer because it indexes its q->qdiscs[] array using the modified queue mapping. The dequeue-side path can also use the stale value through netdev_get_tx_queue() and sch_direct_xmit().
What can happen when an invalid queue mapping reaches these paths?
The dequeue path can index beyond the device transmit-queue allocation, take an out-of-bounds transmit lock, and write txq->xmit_lock_owner beyond the allocation. Drivers that index transmit rings from the queue mapping can likewise access an out-of-range ring, while taprio can index beyond its qdisc array.