Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
To: Aaron Tomlin <atomlin@atomlin.com>
Cc: paul@paul-moore.com, ralf@mips.com, linux-mips@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] mips: sched: Fix CPUMASK_OFFSTACK memory corruption
Date: Mon, 15 Jun 2026 12:29:18 +0200	[thread overview]
Message-ID: <ai_T_uRkojOsTE-Z@alpha.franken.de> (raw)
In-Reply-To: <20260526141651.773306-1-atomlin@atomlin.com>

On Tue, May 26, 2026 at 10:16:51AM -0400, Aaron Tomlin wrote:
> This patch addresses a critical memory management flaw. When
> CONFIG_CPUMASK_OFFSTACK is enabled, cpumask_var_t is a pointer.
> Consequently, sizeof(new_mask) evaluates to the pointer size, causing
> copy_from_user() to clobber the mask pointer. Furthermore, the old
> logic performed copy_from_user() before allocating the mask.
> 
> Fix this by allocating new_mask first. To handle variable-sized user
> masks correctly, use cpumask_size() to truncate overly large user masks
> or pad undersized masks with zeros before copying the data directly into
> the allocated buffer.
> 
> Fixes: 295cbf6d63165 ("[MIPS] Move FPU affinity code into separate file.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Aaron Tomlin <atomlin@atomlin.com>
> ---
> Changes since v2 [1]:
>  - Dropped patch 1. This is to be addressed by the cgroup cpuset
>    maintainer (Waiman Long)
> 
>  - Dropped patch 3. Will be submitted as a separate patch (Paul Moore)
> 
> Changes since v1 [2]:
>  - Reordered the allocation and user-copy of new_mask in the MIPS
>    architecture's mipsmt_sys_sched_setaffinity() to occur before the
>    LSM hook is invoked. This ensures the security modules evaluate a fully
>    populated mask rather than uninitialised memory, while cleanly handling
>    error unwinding
> 
>  - Updated cpuset_can_fork() to pass the destination cpuset's effective CPU
>    mask instead of NULL
> 
> [1]: https://lore.kernel.org/lkml/20260509213803.968464-1-atomlin@atomlin.com/
> [2]: https://lore.kernel.org/lkml/20260509164847.939294-1-atomlin@atomlin.com/
> ---
>  arch/mips/kernel/mips-mt-fpaff.c | 28 +++++++++++++++-------------
>  1 file changed, 15 insertions(+), 13 deletions(-)

applied to mips-next

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

  reply	other threads:[~2026-06-15 10:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-26 14:16 [PATCH v3] mips: sched: Fix CPUMASK_OFFSTACK memory corruption Aaron Tomlin
2026-06-15 10:29 ` Thomas Bogendoerfer [this message]
2026-06-15 12:45   ` Aaron Tomlin

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=ai_T_uRkojOsTE-Z@alpha.franken.de \
    --to=tsbogend@alpha.franken.de \
    --cc=atomlin@atomlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=ralf@mips.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