summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladyslav Tarasiuk <vladyslavt@mellanox.com>2019-12-06 13:51:05 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-12-18 16:05:39 +0100
commit856cf5d1fa71733f76345516e478730510466ade (patch)
tree89c94547c326c184d802a39058c73343a79ac13b
parent5945be9568630c2a7a291dc5d02ddba836223eb7 (diff)
downloadlinux-stable-856cf5d1fa71733f76345516e478730510466ade.tar.gz
linux-stable-856cf5d1fa71733f76345516e478730510466ade.tar.bz2
linux-stable-856cf5d1fa71733f76345516e478730510466ade.zip
mqprio: Fix out-of-bounds access in mqprio_dump
[ Upstream commit 9f104c7736904ac72385bbb48669e0c923ca879b ] 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: 4e8b86c06269 ("mqprio: Introduce new hardware offload mode and shaper in mqprio") Signed-off-by: Vladyslav Tarasiuk <vladyslavt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--net/sched/sch_mqprio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/sched/sch_mqprio.c b/net/sched/sch_mqprio.c
index 0d0113a24962..7b67e4d8e448 100644
--- a/net/sched/sch_mqprio.c
+++ b/net/sched/sch_mqprio.c
@@ -433,7 +433,7 @@ static int mqprio_dump(struct Qdisc *sch, struct sk_buff *skb)
opt.offset[tc] = dev->tc_to_txq[tc].offset;
}
- if (nla_put(skb, TCA_OPTIONS, NLA_ALIGN(sizeof(opt)), &opt))
+ if (nla_put(skb, TCA_OPTIONS, sizeof(opt), &opt))
goto nla_put_failure;
if ((priv->flags & TC_MQPRIO_F_MODE) &&