mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Christian Loehle <christian.loehle@arm.com>
Cc: Tejun Heo <tj@kernel.org>,
	void@manifault.com, sched-ext@lists.linux.dev,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] sched_ext: Mark scx_bpf_cpu_rq as NULL returnable
Date: Wed, 30 Jul 2025 07:50:22 +0200	[thread overview]
Message-ID: <aImynqM32NKYDoE6@gpd4> (raw)
In-Reply-To: <0b8111c6-1b14-41dc-a674-14a6361992b3@arm.com>

Hi Christian,

On Tue, Jul 29, 2025 at 05:03:36PM +0100, Christian Loehle wrote:
> scx_bpf_cpu_rq() obviously returns NULL on invalid cpu.
> Mark it as such.

Makes sense. Maybe add something like the following to the commit message
to better justify why we want the verifier to enforce the NULL check:

While scx_ops_error() is triggered on invalid CPUs, the BPF scheduler
doesn't exit immediately, so there's a window where scx_bpf_cpu_rq() may
return NULL and still be dereferenced.

With something like that:

Acked-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> 
> Cc: stable@vger.kernel.org
> Fixes: 6203ef73fa5c ("sched/ext: Add BPF function to fetch rq")
> Signed-off-by: Christian Loehle <christian.loehle@arm.com>
> ---
>  kernel/sched/ext.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 7dd5cbcb7a06..b734f55f3318 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -7599,7 +7599,7 @@ BTF_ID_FLAGS(func, scx_bpf_get_online_cpumask, KF_ACQUIRE)
>  BTF_ID_FLAGS(func, scx_bpf_put_cpumask, KF_RELEASE)
>  BTF_ID_FLAGS(func, scx_bpf_task_running, KF_RCU)
>  BTF_ID_FLAGS(func, scx_bpf_task_cpu, KF_RCU)
> -BTF_ID_FLAGS(func, scx_bpf_cpu_rq)
> +BTF_ID_FLAGS(func, scx_bpf_cpu_rq, KF_RET_NULL)
>  #ifdef CONFIG_CGROUP_SCHED
>  BTF_ID_FLAGS(func, scx_bpf_task_cgroup, KF_RCU | KF_ACQUIRE)
>  #endif
> -- 
> 2.34.1

      reply	other threads:[~2025-07-30  5:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-29 16:03 Christian Loehle
2025-07-30  5:50 ` 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=aImynqM32NKYDoE6@gpd4 \
    --to=arighi@nvidia.com \
    --cc=christian.loehle@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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

Powered by JetHome