mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCHSET v2 sched_ext/for-7.4-fixes] sched_ext: Fix unbounded format string reads in the bstr kfuncs
@ 2026-11-30 16:18 Andrea Righi
  2026-11-30 16:18 ` [PATCH 1/2] sched_ext: Disallow scx_bpf_dump_bstr() from tracing programs Andrea Righi
  2026-11-30 16:18 ` [PATCH 2/2] sched_ext: Fix unbounded format string reads in the bstr kfuncs Andrea Righi
  0 siblings, 2 replies; 3+ messages in thread
From: Andrea Righi @ 2026-11-30 16:18 UTC (permalink / raw)
  To: Tejun Heo, David Vernet, Changwoo Min
  Cc: Masoud Aghasi, sched-ext, linux-kernel

The format strings passed to the sched_ext bstr kfuncs are only checked
by the verifier to be readable for a single byte, so an unterminated
format makes bpf_bprintf_prepare() scan past the end of the BPF object
[1].

Annotating them with __str would break compatibility in both directions,
since common.bpf.h places the formats in writable .data. Instead, copy
the format into a private kernel buffer with a bounded, fault-safe read
and use only the copy for both preparation and formatting, leaving the
kfunc prototypes and the BPF-side wrappers unchanged.

[1] https://lore.kernel.org/all/20261130054957.570822-1-maghasi@disroot.org

Changes in v2:
 - Add a patch to disallow scx_bpf_dump_bstr() from tracing programs,
   preventing a nested call on the dumping CPU from overwriting the
   format snapshot of the outer call (Sashiko)
 - Link to v1: https://lore.kernel.org/r/20261130075303.1261456-1-arighi@nvidia.com

Andrea Righi (2):
      sched_ext: Disallow scx_bpf_dump_bstr() from tracing programs
      sched_ext: Fix unbounded format string reads in the bstr kfuncs

 kernel/sched/ext/ext.c      | 55 +++++++++++++++++++++++++++----------
 kernel/sched/ext/internal.h |  4 +++
 kernel/sched/ext/types.h    |  1 +
 3 files changed, 46 insertions(+), 14 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 16:18 [PATCHSET v2 sched_ext/for-7.4-fixes] sched_ext: Fix unbounded format string reads in the bstr kfuncs Andrea Righi
2026-11-30 16:18 ` [PATCH 1/2] sched_ext: Disallow scx_bpf_dump_bstr() from tracing programs Andrea Righi
2026-11-30 16:18 ` [PATCH 2/2] sched_ext: Fix unbounded format string reads in the bstr kfuncs Andrea Righi

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®