From: Andrea Righi <arighi@nvidia.com>
To: Masoud Aghasi <maghasi@disroot.org>
Cc: sched-ext@lists.linux.dev, tj@kernel.org, void@manifault.com,
changwoo@igalia.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH sched_ext/for-7.4-fixes v2] sched_ext: Fix kernel OOB memory read in scx_bpf_x_bstr kfuncs
Date: Mon, 30 Nov 2026 08:57:44 +0100 [thread overview]
Message-ID: <aw0sePKGSuoI1Erk@gpd4> (raw)
In-Reply-To: <aw0k2SsiRs5NRtAv@gpd4>
On Mon, Nov 30, 2026 at 08:25:13AM +0100, Andrea Righi wrote:
> Hi Masoud,
>
> On Mon, Nov 30, 2026 at 05:49:57AM +0000, Masoud Aghasi wrote:
> > The format string arguments of the sched_ext BPF kfuncs ending in
> > _bstr() are passed to bpf_bprintf_prepare(), which searches for
> > a terminating NUL using strnchr().
> >
> > Previously, the verifier only checked that these pointers were
> > accessible for a single byte. It did not guarantee that the format
> > strings were NUL-terminated. Consequently, an unterminated format
> > string could cause an out-of-bounds read during the initial
> > strnchr() call.
> >
> > Additionally, format strings larger than INT_MAX could cause
> > signed integer overflow in the subsequent formatting loop, which
> > uses an int index. This could result in out-of-bounds accesses
> > regardless of whether the format string was NUL-terminated.
> >
> > Annotate the format string arguments with __str so the verifier
> > validates that they point to valid NUL-terminated strings.
> >
> > Also, limit the maximum format string length to INT_MAX to
> > prevent signed integer overflow in the formatting loop.
> >
> > Fixes: f0e1a0643a59 ("sched_ext: Implement BPF extensible scheduler class")
> > Signed-off-by: Masoud Aghasi <maghasi@disroot.org>
>
> There's one issue I didn't consider in my previous review, this breaks
> compatibility with existing BPF schedulers in both directions (see
> below).
This should fix the issue maintaining backward and forward compatibility
with the BPF schedulers:
https://lore.kernel.org/r/20261130075303.1261456-1-arighi@nvidia.com
Masoud, can you take a look and see if it makes sense?
Thanks!
-Andrea
prev parent reply other threads:[~2026-11-30 7:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 5:49 Masoud Aghasi
2026-11-30 7:25 ` Andrea Righi
2026-11-30 7:57 ` Andrea Righi [this message]
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=aw0sePKGSuoI1Erk@gpd4 \
--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 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®