* [RESEND PATCH v2] net: prevent user from passing illegal stab size
@ 2021-09-28 3:11 王贇
2021-09-28 5:11 ` Cong Wang
0 siblings, 1 reply; 3+ messages in thread
From: 王贇 @ 2021-09-28 3:11 UTC (permalink / raw)
To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
Jakub Kicinski, open list:TC subsystem, open list
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>
---
include/net/pkt_sched.h | 1 +
net/sched/sch_api.c | 6 ++++++
2 files changed, 7 insertions(+)
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 6d7b12c..bf79f3a 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;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 5e90e9b..12f39a2 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -513,6 +513,12 @@ static struct qdisc_size_table *qdisc_get_stab(struct nlattr *opt,
return stab;
}
+ if (s->size_log > STAB_SIZE_LOG_MAX ||
+ s->cell_log > STAB_SIZE_LOG_MAX) {
+ NL_SET_ERR_MSG(extack, "Invalid logarithmic size of size table");
+ return ERR_PTR(-EINVAL);
+ }
+
stab = kmalloc(sizeof(*stab) + tsize * sizeof(u16), GFP_KERNEL);
if (!stab)
return ERR_PTR(-ENOMEM);
--
1.8.3.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RESEND PATCH v2] net: prevent user from passing illegal stab size
2021-09-28 3:11 [RESEND PATCH v2] net: prevent user from passing illegal stab size 王贇
@ 2021-09-28 5:11 ` Cong Wang
2021-09-28 5:34 ` 王贇
0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2021-09-28 5:11 UTC (permalink / raw)
To: 王贇
Cc: Jamal Hadi Salim, Jiri Pirko, David S. Miller, Jakub Kicinski,
open list:TC subsystem, open list
Hi,
It has been applied, no need to resend.
commit b193e15ac69d56f35e1d8e2b5d16cbd47764d053
Author: 王贇 <yun.wang@linux.alibaba.com>
AuthorDate: Fri Sep 24 10:35:58 2021 +0800
Commit: David S. Miller <davem@davemloft.net>
CommitDate: Sun Sep 26 11:09:07 2021 +0100
net: prevent user from passing illegal stab size
Thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RESEND PATCH v2] net: prevent user from passing illegal stab size
2021-09-28 5:11 ` Cong Wang
@ 2021-09-28 5:34 ` 王贇
0 siblings, 0 replies; 3+ messages in thread
From: 王贇 @ 2021-09-28 5:34 UTC (permalink / raw)
To: Cong Wang
Cc: Jamal Hadi Salim, Jiri Pirko, David S. Miller, Jakub Kicinski,
open list:TC subsystem, open list
My bad... failed to get the notify, please ignore the noise.
Regards,
Michael Wang
On 2021/9/28 下午1:11, Cong Wang wrote:
> Hi,
>
> It has been applied, no need to resend.
>
> commit b193e15ac69d56f35e1d8e2b5d16cbd47764d053
> Author: 王贇 <yun.wang@linux.alibaba.com>
> AuthorDate: Fri Sep 24 10:35:58 2021 +0800
> Commit: David S. Miller <davem@davemloft.net>
> CommitDate: Sun Sep 26 11:09:07 2021 +0100
>
> net: prevent user from passing illegal stab size
>
> Thanks.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-28 5:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 3:11 [RESEND PATCH v2] net: prevent user from passing illegal stab size 王贇
2021-09-28 5:11 ` Cong Wang
2021-09-28 5:34 ` 王贇
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®