From: Shrikanth Hegde <sshegde@linux.ibm.com>
To: "Ritesh Harjani (IBM)" <ritesh.list@gmail.com>,
linuxppc-dev@lists.ozlabs.org,
Nathan Chancellor <nathan@kernel.org>,
Kees Cook <kees@kernel.org>
Cc: Madhavan Srinivasan <maddy@linux.ibm.com>,
Venkat Rao Bagalkote <venkat88@linux.ibm.com>,
linux-kernel@vger.kernel.org, chleroy@kernel.org,
Michael Ellerman <mpe@ellerman.id.au>,
Nicholas Piggin <npiggin@gmail.com>
Subject: Re: [PATCH] powerpc/smp: Handle missing ibm,thread-groups in parse_thread_groups()
Date: Tue, 10 Nov 2026 20:07:46 +0530 [thread overview]
Message-ID: <e6b47bd5-425d-4c8e-8c68-5a36d47bd977@linux.ibm.com> (raw)
In-Reply-To: <39282c731de90f47678952e471236ef22e9d4b15.1794317777.git.ritesh.list@gmail.com>
Hi Ritesh,
+cc nathan, Kees,
On 11/10/26 7:13 PM, Ritesh Harjani (IBM) wrote:
> Power systems can have ibm,thread-groups properly absent like in one of
> the PowerNV Power9 boxes where there was a warning splat reported on
> 7.4-rc2:
>
> WARNING: mm/slub.c:5459 at ___kmalloc_large_node+0x174/0x1a0, CPU#124: swapper/124/1
> ...
> Call Trace:
> __kmalloc_noprof+0x490/0x690
> _kzalloc_noprof.constprop.0+0x1c/0x7c
> init_thread_group_cache_map+0xd0/0x2d4
> smp_prepare_cpus+0x2bc/0x484
> kernel_init_freeable+0x168/0x3c4
> kernel_init+0x34/0x1ac
>
> This happens because today we don't check for whether the properly is
> present or not and directly pass the return value of
> of_property_count_u32_elems(), to the allocator.
>
> This went unnoticed because earlier kcalloc() caught the overflow due to
> check_mul_overflow() check and returned NULL.
> But since commit 0af298e62e5c ("treewide: refresh kmalloc_obj()
> conversions") switched this call to kzalloc_objs(), size_mul() saturates
> the size to SIZE_MAX instead and we now get a warning at boot.
>
> Bail out early if the property is missing or empty. Follow the return
> value as documented in kernel doc of parse_thread_groups() function.
>
> Fixes: 790a1662d3a2 ("powerpc/smp: Parse ibm,thread-groups with multiple properties")
> Reported-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
> ---
> arch/powerpc/kernel/smp.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
> index 7a25eaa59e62..9a0f63e43821 100644
> --- a/arch/powerpc/kernel/smp.c
> +++ b/arch/powerpc/kernel/smp.c
> @@ -824,6 +824,10 @@ static int parse_thread_groups(struct device_node *dn,
> int i = 0;
>
> count = of_property_count_u32_elems(dn, "ibm,thread-groups");
> + if (count < 0)
> + return count;
> + if (!count)
> + return -ENODATA;
This zero count check is not necessary.
Code doesn;t dereference thread_group_array if the count is 0.
...
while (i < count && property_idx < MAX_THREAD_GROUP_PROPERTIES) {
...
out_free:
kfree(thread_group_array);
return ret;
Which should naturally pass to kfree which is expected to handle ZERO_SIZE_PTR.
No?
> thread_group_array = kzalloc_objs(u32, count);
> if (!thread_group_array)
> return -ENOMEM;
> --
> 2.39.5
>
Nathan reported the same issue on QEMU.The same symptoms.
https://lore.kernel.org/all/20261109-powerpc-smp-handle-count-err-v1-1-e777fde7f71a@kernel.org/
next prev parent reply other threads:[~2026-11-10 14:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 13:43 Ritesh Harjani (IBM)
2026-11-10 14:37 ` Shrikanth Hegde [this message]
2026-11-10 15:23 ` Ritesh Harjani
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=e6b47bd5-425d-4c8e-8c68-5a36d47bd977@linux.ibm.com \
--to=sshegde@linux.ibm.com \
--cc=chleroy@kernel.org \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=maddy@linux.ibm.com \
--cc=mpe@ellerman.id.au \
--cc=nathan@kernel.org \
--cc=npiggin@gmail.com \
--cc=ritesh.list@gmail.com \
--cc=venkat88@linux.ibm.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®