net: ioam6: fix OOB and missing lock
Subsystems (3)
Justin Iurman
maintainerPATCH 1/1 net: ioam6: fix OOB and missing lock
When trace->type.bit6 is set:
if (trace->type.bit6) {
...
queue = skb_get_tx_queue(dev, skb);
qdisc = rcu_dereference(queue->qdisc);This code can lead to an out-of-bounds access of the dev->_tx[] array when is_input is true. In such a case, the packet is on the RX path and skb->queue_mapping contains the RX queue index of the ingress device. If the ingress device has more RX queues than the egress device (dev) has TX queues, skb_get_queue_mapping(skb) will exceed dev->num_tx_queues. Add a check to avoid this situation since skb_get_tx_queue() does not clamp the index. This issue has also revealed that per queue visibility cannot be accurate and will be replaced later as a new feature.
While at it, add missing lock around qdisc_qstats_qlen_backlog(). The function __ioam6_fill_trace_data() is called from both softirq and process contexts, hence the use of spin_lock_bh() here.
--- net/ipv6/ioam6.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/ipv6/ioam6.c +5 -1
@@ -803,12 +803,16 @@ static void __ioam6_fill_trace_data(struct sk_buff *skb,struct Qdisc *qdisc;__u32 qlen, backlog; -if (dev->flags &IFF_LOOPBACK ) { +if (dev->flags &IFF_LOOPBACK || +skb_get_queue_mapping (skb) >= dev->num_tx_queues) { *(__be32 *)data =cpu_to_be32 (IOAM6_U32_UNAVAILABLE ); }else { queue =skb_get_tx_queue (dev, skb); qdisc =rcu_dereference (queue->qdisc); + +spin_lock_bh (qdisc_lock (qdisc));qdisc_qstats_qlen_backlog (qdisc, &qlen, &backlog); +spin_unlock_bh (qdisc_lock (qdisc)); *(__be32 *)data =cpu_to_be32 (backlog); }
Signature · 1 line
2.34.1
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Sat, 4 Apr 2026 15:41:37 +0200 you wrote:
When
trace->type.bit6is set:if (trace->type.bit6) { ... queue = skb_get_tx_queue(dev, skb); qdisc = rcu_dereference(queue->qdisc);[...]
Here is the summary with links:
- [net] net: ioam6: fix OOB and missing lock
https://git.kernel.org/netdev/net/c/b30b1675aa2b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html