mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Cong Wang <xiyou.wangcong@gmail.com>,
	linux-kernel@vger.kernel.org,
	Thomas Gleixner <tglx@linutronix.de>
Cc: peterz@infradead.org, Cong Wang <cwang@multikernel.io>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] sched: Fix NULL mm dereference in sched_mm_cid_after_execve()
Date: Wed, 24 Dec 2025 09:28:38 -0500	[thread overview]
Message-ID: <d6ac8fe9-5fc0-4042-9592-cde3db82b65e@efficios.com> (raw)
In-Reply-To: <20251223215113.639686-1-xiyou.wangcong@gmail.com>

On 2025-12-23 16:51, Cong Wang wrote:
> From: Cong Wang <cwang@multikernel.io>
> 
> sched_mm_cid_after_execve() is called in bprm_execve()'s cleanup path
> even when exec_binprm() fails. For the init task's first execve, this
> causes a problem:
> 
> 1. current->mm is NULL (kernel threads don't have an mm)
> 2. sched_mm_cid_before_execve() exits early because mm is NULL
> 3. exec_binprm() fails (e.g., ENOENT for missing script interpreter)
> 4. sched_mm_cid_after_execve() is called with mm still NULL
> 5. sched_mm_cid_fork() is called unconditionally, triggering WARN_ON
> 
> This is easily reproduced by booting with an init that is a shell script
> (#!/bin/sh) where the interpreter doesn't exist in the initramfs.
> 
> Fix this by checking if t->mm is NULL before calling sched_mm_cid_fork(),
> matching the behavior of sched_mm_cid_before_execve() which already
> handles this case via sched_mm_cid_exit()'s early return.
 >
 > Fixes: b0c3d51b54f8 ("sched/mmcid: Provide precomputed maximal value")
 > Cc: Thomas Gleixner <tglx@linutronix.de>
 > Signed-off-by: Cong Wang <cwang@multikernel.io>

Thanks for the detailed explanation.

Indeed, the offending commit removes a pre-existing NULL mm check:

  void sched_mm_cid_after_execve(struct task_struct *t)
  {
-       struct mm_struct *mm = t->mm;
-
-       if (!mm)
-               return;

Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

Thomas, Peter, Ingo, can we fast-track this fix for upstream ?

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

  reply	other threads:[~2025-12-24 14:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-23 21:51 Cong Wang
2025-12-24 14:28 ` Mathieu Desnoyers [this message]
2025-12-30 17:03 ` Qing Wang
2026-01-07 18:00 ` Will Deacon
2026-01-08 15:28   ` Mathieu Desnoyers
2026-01-09 11:53     ` Thomas Gleixner
2026-01-09 13:23       ` Mathieu Desnoyers
2026-01-09 12:05 ` [tip: sched/urgent] sched/mm_cid: Prevent " tip-bot2 for Cong Wang

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=d6ac8fe9-5fc0-4042-9592-cde3db82b65e@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=cwang@multikernel.io \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=xiyou.wangcong@gmail.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®