From: Waiman Long <llong@redhat.com>
To: Chen Ridong <chenridong@huaweicloud.com>,
tj@kernel.org, hannes@cmpxchg.org, mkoutny@suse.com
Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
lujialin4@huawei.com
Subject: Re: [PATCH -next] cgroup/cpuset: fix null-ptr-deref in rebuild_sched_domains_cpuslocked
Date: Wed, 25 Feb 2026 01:34:41 -0500 [thread overview]
Message-ID: <35c806f0-39ba-42c2-87f2-f3f3a6772ed2@redhat.com> (raw)
In-Reply-To: <20260225011523.51365-1-chenridong@huaweicloud.com>
On 2/24/26 8:15 PM, Chen Ridong wrote:
> From: Chen Ridong <chenridong@huawei.com>
>
> A null-pointer-dereference bug was reported by syzbot:
>
> Oops: general protection fault, probably for address 0xdffffc0000000000:
> KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
> RIP: 0010:bitmap_subset include/linux/bitmap.h:433 [inline]
> RIP: 0010:cpumask_subset include/linux/cpumask.h:836 [inline]
> RIP: 0010:rebuild_sched_domains_locked kernel/cgroup/cpuset.c:967
> RSP: 0018:ffffc90003ecfbc0 EFLAGS: 00010246
> RAX: 0000000000000000 RBX: 0000000000000001 RCX: 0000000000000020
> RDX: ffff888028de0000 RSI: ffffffff8200f003 RDI: ffffffff8df14f28
> RBP: 0000000000000000 R08: 0000000000000cc0 R09: 00000000ffffffff
> R10: ffffffff8e7d95b3 R11: 0000000000000001 R12: 0000000000000000
> R13: 00000000000f4240 R14: dffffc0000000000 R15: 0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000001b2f463fff CR3: 000000003704c000 CR4: 00000000003526f0
> Call Trace:
> <TASK>
> rebuild_sched_domains_cpuslocked kernel/cgroup/cpuset.c:983 [inline]
> rebuild_sched_domains+0x21/0x40 kernel/cgroup/cpuset.c:990
> sched_rt_handler+0xb5/0xe0 kernel/sched/rt.c:2911
> proc_sys_call_handler+0x47f/0x5a0 fs/proc/proc_sysctl.c:600
> new_sync_write fs/read_write.c:595 [inline]
> vfs_write+0x6ac/0x1070 fs/read_write.c:688
> ksys_write+0x12a/0x250 fs/read_write.c:740
> do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
> do_syscall_64+0x106/0xf80 arch/x86/entry/syscall_64.c:94
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> The issue occurs when generate_sched_domains() returns ndoms = 1 and
> doms = NULL due to a kmalloc failure. This leads to a null-pointer
> dereference when accessing doms in rebuild_sched_domains_locked().
>
> Fix this by adding a NULL check for doms before accessing it.
>
> Fixes: 6ee43047e8ad ("cpuset: Remove unnecessary checks in rebuild_sched_domains_locked")
> Reported-by: syzbot+460792609a79c085f79f@syzkaller.appspotmail.com
> Signed-off-by: Chen Ridong <chenridong@huawei.com>
> ---
> kernel/cgroup/cpuset.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 9faf34377a88..8ebf2ab8f0df 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -962,7 +962,8 @@ void rebuild_sched_domains_locked(void)
> * prevent the panic.
> */
> for (i = 0; i < ndoms; ++i) {
> - if (WARN_ON_ONCE(!cpumask_subset(doms[i], cpu_active_mask)))
> + if (doms && WARN_ON_ONCE(!cpumask_subset(doms[i],
> + cpu_active_mask)))
> return;
> }
>
I would prefer putting the doms check in the for loop without the line
wrap, but that will work too.
Acked-by: Waiman Long <longman@redhat.com>
next prev parent reply other threads:[~2026-02-25 6:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-25 1:15 Chen Ridong
2026-02-25 6:34 ` Waiman Long [this message]
2026-02-25 17:40 ` Tejun Heo
2026-02-26 0:40 ` Chen Ridong
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=35c806f0-39ba-42c2-87f2-f3f3a6772ed2@redhat.com \
--to=llong@redhat.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huaweicloud.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lujialin4@huawei.com \
--cc=mkoutny@suse.com \
--cc=tj@kernel.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®