summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
author王贇 <yun.wang@linux.alibaba.com>2021-09-24 10:35:58 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-10-17 10:43:33 +0200
commitbda06aff03a1fe0530a8245ef0988e5ba01ea915 (patch)
tree52b45ad71ecebfdfe217cafbd96895729c783616 /include/net
parent3d68c7b0ab5b5b9fd7a2a8b13114ac0336e23a30 (diff)
downloadlinux-stable-bda06aff03a1fe0530a8245ef0988e5ba01ea915.tar.gz
linux-stable-bda06aff03a1fe0530a8245ef0988e5ba01ea915.tar.bz2
linux-stable-bda06aff03a1fe0530a8245ef0988e5ba01ea915.zip
net: prevent user from passing illegal stab size
[ Upstream commit b193e15ac69d56f35e1d8e2b5d16cbd47764d053 ] We observed below report when playing with netlink sock: UBSAN: shift-out-of-bounds in net/sched/sch_api.c:580:10 shift exponent 249 is too large for 32-bit type CPU: 0 PID: 685 Comm: a.out Not tainted Call Trace: dump_stack_lvl+0x8d/0xcf ubsan_epilogue+0xa/0x4e __ubsan_handle_shift_out_of_bounds+0x161/0x182 __qdisc_calculate_pkt_len+0xf0/0x190 __dev_queue_xmit+0x2ed/0x15b0 it seems like kernel won't check the stab log value passing from user, and will use the insane value later to calculate pkt_len. This patch just add a check on the size/cell_log to avoid insane calculation. Reported-by: Abaci <abaci@linux.alibaba.com> Signed-off-by: Michael Wang <yun.wang@linux.alibaba.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/pkt_sched.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 2be90a54a404..7e58b4470570 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -11,6 +11,7 @@
#include <uapi/linux/pkt_sched.h>
#define DEFAULT_TX_QUEUE_LEN 1000
+#define STAB_SIZE_LOG_MAX 30
struct qdisc_walker {
int stop;