]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
mqprio: Fix out-of-bounds access in mqprio_dump
authorVladyslav Tarasiuk <vladyslavt@mellanox.com>
Fri, 6 Dec 2019 13:51:05 +0000 (13:51 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 29 Jan 2020 04:45:21 +0000 (23:45 -0500)
commitba23b45807607eb6a80865f9d27098af4b56e5a7
treeae44f5830c9f2967d3d75262a6ced24c66278aa2
parente4a6f3f1e8983ac0231433e24daebbca66a4574f
mqprio: Fix out-of-bounds access in mqprio_dump

BugLink: https://bugs.launchpad.net/bugs/1859249
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/sched/sch_mqprio.c