mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Masoud Aghasi <maghasi@disroot.org>
To: Andrea Righi <arighi@nvidia.com>
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] sched_ext: Fix kernel OOB memory read in scx_bpf_x_bstr kfuncs
Date: Sun, 29 Nov 2026 15:33:52 +0000	[thread overview]
Message-ID: <8d7f4311-4664-4410-9010-4ebd9baa7365@disroot.org> (raw)
In-Reply-To: <awwymLdpQ105Xw5O@gpd4>

On 29/11/2026 14:11, Andrea Righi wrote:
> Hi Masoud,
> 
> On Sun, Nov 29, 2026 at 09:35:55AM +0000, Masoud Aghasi wrote:
>> For scx_bpf_exit_bstr(), scx_bpf_error_bstr(), scx_bpf_dump_bstr()
>> and scx_bpf_sub_kill_bstr() kfuncs, fmt parameter is defined as a
>> dynamic string pointer which could be of any length. This causes a
>> kernel out-of-bound memory read inside the bpf_bprintf_prepare()
>> for loop, when passing strings with lengths higher than INT_MAX.
> 
> Actually I think the OOB doesn't require a string longer than INT_MAX,
> the verifier only checks one byte of fmt, so an unterminated buffer can
> also overrun in the initial strnchr(), before reaching the loop. We
> should probably clarify this in the description.
> 
> And, as reported by Sashiko, ___fmt needs to be const, otherwise the
> existing wrappers fail verification. Please also fix the kernel-doc
> parameter names.
> 
> Thanks,
> -Andrea
> 

Hi Andrea, thanks for the review.
Yes, you are right about the OOB read of strings shorter than INT_MAX,
without __str suffix.
I will add these changes to the V2.

      reply	other threads:[~2026-11-29 15:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-29  9:35 Masoud Aghasi
2026-11-29  9:54 ` Masoud Aghasi
2026-11-29 14:11 ` Andrea Righi
2026-11-29 15:33   ` Masoud Aghasi [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=8d7f4311-4664-4410-9010-4ebd9baa7365@disroot.org \
    --to=maghasi@disroot.org \
    --cc=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.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®