All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>, David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>
Cc: Masoud Aghasi <maghasi@disroot.org>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] sched_ext: Disallow scx_bpf_dump_bstr() from tracing programs
Date: Mon, 30 Nov 2026 17:18:27 +0100	[thread overview]
Message-ID: <20261130161913.1379563-2-arighi@nvidia.com> (raw)
In-Reply-To: <20261130161913.1379563-1-arighi@nvidia.com>

scx_bpf_dump_bstr() is in scx_kfunc_ids_any, so tracing programs can
call it too. However, it's only meaningful from ops.dump(),
ops.dump_cpu() and ops.dump_task(): called from any other CPU, it just
aborts the scheduler.

Moreover, a tracing program running on the dumping CPU in the middle of
another scx_bpf_dump_bstr() call (e.g., attached to a function invoked
while formatting) can clobber the shared buffers in scx_dump_data that
the outer call is still using, corrupting the dump output.

Add scx_bpf_dump_bstr() to scx_kfunc_ids_no_tracing, so that tracing
programs calling it are rejected at load time.

Fixes: 07814a9439a3 ("sched_ext: Print debug dump after an error exit")
Link: https://lore.kernel.org/r/sashiko-outbox-240675@kernel.org
Signed-off-by: Andrea Righi <arighi@nvidia.com>
---
 kernel/sched/ext/ext.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/sched/ext/ext.c b/kernel/sched/ext/ext.c
index a4a93ed97f7b6..928652dbeb1b4 100644
--- a/kernel/sched/ext/ext.c
+++ b/kernel/sched/ext/ext.c
@@ -12267,6 +12267,10 @@ static const struct btf_kfunc_id_set scx_kfunc_set_any = {
  * arbitrary tracing context. One that calls scx_bpf_cidperf_set() hits the
  * deadlock above.
  *
+ * scx_bpf_dump_bstr() is only meaningful from ops.dump*(). A tracing program
+ * can run on the dumping CPU in the middle of another scx_bpf_dump_bstr()
+ * call and clobber its shared format and line buffers.
+ *
  * Members must also stay in scx_kfunc_ids_any so that struct_ops and syscall
  * programs keep their access.
  */
@@ -12278,6 +12282,7 @@ BTF_ID_FLAGS(func, scx_bpf_sub_revoke, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, scx_bpf_destroy_dsq, KF_IMPLICIT_ARGS)
 BTF_ID_FLAGS(func, bpf_iter_scx_dsq_next, KF_ITER_NEXT | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_scx_dsq_destroy, KF_ITER_DESTROY)
+BTF_ID_FLAGS(func, scx_bpf_dump_bstr, KF_IMPLICIT_ARGS)
 BTF_KFUNCS_END(scx_kfunc_ids_no_tracing)
 
 /*
-- 
2.56.1


  reply	other threads:[~2026-11-30 16:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Andrea Righi [this message]
2026-11-30 16:18 ` [PATCH 2/2] " Andrea Righi
2026-11-30 16:41   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130161913.1379563-2-arighi@nvidia.com \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maghasi@disroot.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.