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 size_log passing from
user, and will use the insane value later to calculate pkt_len.
This patch just add a check on the size_log to avoid insane
calculation.
Reported-by: Abaci <redacted>
Signed-off-by: Michael Wang <redacted>
---
include/uapi/linux/pkt_sched.h | 1 +
net/sched/sch_api.c | 3 +++
2 files changed, 4 insertions(+)
From: Jakub Kicinski <kuba@kernel.org> Date: 2021-09-23 16:01:09
On Thu, 23 Sep 2021 17:08:13 +0800 王贇 wrote:
quoted hunk
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 size_log passing from
user, and will use the insane value later to calculate pkt_len.
This patch just add a check on the size_log to avoid insane
calculation.
Reported-by: Abaci <redacted>
Signed-off-by: Michael Wang <redacted>
---
include/uapi/linux/pkt_sched.h | 1 +
net/sched/sch_api.c | 3 +++
2 files changed, 4 insertions(+)
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 size_log passing from
user, and will use the insane value later to calculate pkt_len.
This patch just add a check on the size_log to avoid insane
calculation.
Reported-by: Abaci <redacted>
Signed-off-by: Michael Wang <redacted>
---
include/uapi/linux/pkt_sched.h | 1 +
net/sched/sch_api.c | 3 +++
2 files changed, 4 insertions(+)
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 <redacted>
Signed-off-by: Michael Wang <redacted>
---
include/net/pkt_sched.h | 1 +
net/sched/sch_api.c | 6 ++++++
2 files changed, 7 insertions(+)