From: Andrea Righi <arighi@nvidia.com>
To: liuwenfang <liuwenfang@honor.com>
Cc: 'Tejun Heo' <tj@kernel.org>, 'David Vernet' <void@manifault.com>,
'Changwoo Min' <changwoo@igalia.com>,
'Ingo Molnar' <mingo@redhat.com>,
'Peter Zijlstra' <peterz@infradead.org>,
'Juri Lelli' <juri.lelli@redhat.com>,
'Vincent Guittot' <vincent.guittot@linaro.org>,
'Dietmar Eggemann' <dietmar.eggemann@arm.com>,
'Steven Rostedt' <rostedt@goodmis.org>,
'Ben Segall' <bsegall@google.com>, 'Mel Gorman' <mgorman@suse.de>,
'Valentin Schneider' <vschneid@redhat.com>,
"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched_ext: Fix NULL pointer dereferences in put_prev_task_scx
Date: Mon, 9 Jun 2025 14:09:00 +0200 [thread overview]
Message-ID: <aEbO3DmwY4Tg6HT1@gpd4> (raw)
In-Reply-To: <dc2d908cd429473a9d46255272231f38@honor.com>
On Mon, Jun 09, 2025 at 11:36:15AM +0000, liuwenfang wrote:
> As put_prev_task can be used in other kernel modules which can lead
> to a NULL pointer. Fix this by checking for a valid next.
Actually, put_prev_task() should be used only within kernel/sched/ and, in
theory, you should have done a dequeue_task() before put_prev_task() in
this scenario, so SCX_TASK_QUEUED shouldn't be set in p->scx.flags.
The change might still make sense, but can you clarify how you triggered
the NULL pointer dereference?
Thanks,
-Andrea
>
> Signed-off-by: l00013971 <l00013971@hihonor.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 f5133249f..6a579babd 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -3262,7 +3262,7 @@ static void put_prev_task_scx(struct rq *rq, struct task_struct *p,
> * ops.enqueue() that @p is the only one available for this cpu,
> * which should trigger an explicit follow-up scheduling event.
> */
> - if (sched_class_above(&ext_sched_class, next->sched_class)) {
> + if (next && sched_class_above(&ext_sched_class, next->sched_class)) {
> WARN_ON_ONCE(!static_branch_unlikely(&scx_ops_enq_last));
> do_enqueue_task(rq, p, SCX_ENQ_LAST, -1);
> } else {
> --
> 2.17.1
next prev parent reply other threads:[~2025-06-09 12:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-09 11:36 [PATCH] sched_ext: Fix NULL pointer dereferences in put_prev_task_scx liuwenfang
2025-06-09 12:09 ` Andrea Righi [this message]
2025-06-10 6:22 ` 回复: " liuwenfang
2025-06-11 6:37 ` Andrea Righi
2025-06-11 7:17 ` liuwenfang
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=aEbO3DmwY4Tg6HT1@gpd4 \
--to=arighi@nvidia.com \
--cc=bsegall@google.com \
--cc=changwoo@igalia.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liuwenfang@honor.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=void@manifault.com \
--cc=vschneid@redhat.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