From: Waiman Long <longman@redhat.com>
To: Joe Korty <joe.korty@concurrent-rt.com>
Cc: linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>
Subject: Re: [BUG 6.4] sched/core: Possible buffer overflow in do_set_cpu_allowed
Date: Fri, 7 Jul 2023 19:24:00 -0400 [thread overview]
Message-ID: <9a3cb0c2-0b1a-28d0-0ebf-c29c6cb37f29@redhat.com> (raw)
In-Reply-To: <20230707202851.GA4231@zipoli.concurrent-rt.com>
On 7/7/23 16:28, Joe Korty wrote:
> In commit 9a5418bc48bab ("sched/core: Use kfree_rcu() in
> do_set_cpus_allowed()"), a kfree_rcu() is used to free a cpu mask.
> However, cpu masks can be as short as 8 bytes and this is a problem,
> as kfree_rcu requires the to-be freed buffer to be at least 16 bytes.
> Thus there is a chance of buffer overflow corruption when the number of
> possible cpus in the system is 64 or less.
>
> I have not seen this corruption in the wild. I only noticed this possibility
> when reviewing the scheduler differences between 6.1 and 6.4.
We were aware of this known limitation. If you look at
alloc_user_cpus_ptr():
static cpumask_t *alloc_user_cpus_ptr(int node)
{
/*
* See do_set_cpus_allowed() above for the rcu_head usage.
*/
int size = max_t(int, cpumask_size(), sizeof(struct rcu_head));
return kmalloc_node(size, GFP_KERNEL, node);
}
We made sure that the allocated buffer is big enough to hold struct
rcu_head.
Cheers,
Longman
prev parent reply other threads:[~2023-07-07 23:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 20:28 Joe Korty
2023-07-07 23:24 ` Waiman Long [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=9a3cb0c2-0b1a-28d0-0ebf-c29c6cb37f29@redhat.com \
--to=longman@redhat.com \
--cc=joe.korty@concurrent-rt.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
/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®