Skip to content

Commit 9f104c7

Browse files
Hoommusdavem330
authored andcommitted
mqprio: Fix out-of-bounds access in mqprio_dump
When user runs a command like tc qdisc add dev eth1 root mqprio KASAN stack-out-of-bounds warning is emitted. Currently, NLA_ALIGN macro used in mqprio_dump provides too large buffer size as argument for nla_put and memcpy down the call stack. The flow looks like this: 1. nla_put expects exact object size as an argument; 2. Later it provides this size to memcpy; 3. To calculate correct padding for SKB, nla_put applies NLA_ALIGN macro itself. Therefore, NLA_ALIGN should not be applied to the nla_put parameter. Otherwise it will lead to out-of-bounds memory access in memcpy. Fixes: 4e8b86c ("mqprio: Introduce new hardware offload mode and shaper in mqprio") Signed-off-by: Vladyslav Tarasiuk <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f421031 commit 9f104c7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/sched/sch_mqprio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
434434
opt.offset[tc] = dev->tc_to_txq[tc].offset;
435435
}
436436

437-
if (nla_put(skb, TCA_OPTIONS, NLA_ALIGN(sizeof(opt)), &opt))
437+
if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
438438
goto nla_put_failure;
439439

440440
if ((priv->flags & TC_MQPRIO_F_MODE) &&

0 commit comments

Comments
 (0)