* [PATCH v2] sched_ext: reject oversized exit_dump_len
@ 2026-11-24 16:15 Sechang Lim
2026-11-24 17:57 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Sechang Lim @ 2026-11-24 16:15 UTC (permalink / raw)
To: Tejun Heo
Cc: David Vernet, Andrea Righi, Changwoo Min, sched-ext, linux-kernel
When a BPF scheduler is enabled, alloc_exit_info() allocates the exit
dump buffer with kvzalloc(ops->exit_dump_len). bpf_scx_init_member()
stores exit_dump_len from the struct_ops map value without an upper
bound, so a length above INT_MAX reaches kvzalloc(), which warns and
fails, and the enable fails with -ENOMEM.
bpf_scx_init_member() already rejects oversized dispatch_max_batch and
timeout_ms values with -E2BIG. Reject an exit_dump_len above INT_MAX in
the same way, so that the map update fails before the value is used.
Fixes: 07814a9439a3 ("sched_ext: Print debug dump after an error exit")
Signed-off-by: Sechang Lim <rhkrqnwk98@gmail.com>
---
v2:
- Read exit_dump_len once into a local (Tejun)
v1: https://lore.kernel.org/all/20261124100508.1060692-1-rhkrqnwk98@gmail.com/
kernel/sched/ext/ext.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index 10de6bd865e8..18bfb1815a4a 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -9220,10 +9220,14 @@ static int bpf_scx_init_member(const struct btf_type *t,
return -E2BIG;
ops->timeout_ms = *(u32 *)(udata + moff);
return 1;
- case offsetof(struct sched_ext_ops, exit_dump_len):
- ops->exit_dump_len =
- *(u32 *)(udata + moff) ?: SCX_EXIT_DUMP_DFL_LEN;
+ case offsetof(struct sched_ext_ops, exit_dump_len): {
+ u32 dump_len = *(u32 *)(udata + moff);
+
+ if (dump_len > INT_MAX)
+ return -E2BIG;
+ ops->exit_dump_len = dump_len ?: SCX_EXIT_DUMP_DFL_LEN;
return 1;
+ }
case offsetof(struct sched_ext_ops, hotplug_seq):
ops->hotplug_seq = *(u64 *)(udata + moff);
return 1;
--
2.56.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] sched_ext: reject oversized exit_dump_len
2026-11-24 16:15 [PATCH v2] sched_ext: reject oversized exit_dump_len Sechang Lim
@ 2026-11-24 17:57 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2026-11-24 17:57 UTC (permalink / raw)
To: Sechang Lim
Cc: David Vernet, Andrea Righi, Changwoo Min, sched-ext, linux-kernel
Applied to sched_ext/for-7.5 with the Fixes tag dropped.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-24 17:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-24 16:15 [PATCH v2] sched_ext: reject oversized exit_dump_len Sechang Lim
2026-11-24 17:57 ` Tejun Heo
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®