* [PATCH] md/raid5: Fix out-of-bounds access on non-contiguous NUMA nodes
@ 2026-11-23 18:24 Bart Van Assche
2026-11-29 4:17 ` yu kuai
0 siblings, 1 reply; 3+ messages in thread
From: Bart Van Assche @ 2026-11-23 18:24 UTC (permalink / raw)
To: Song Liu, Yu Kuai
Cc: Li Nan, Xiao Ni, linux-raid, Bart Van Assche, stable,
Patrick Bernier
Prevent out-of-bounds array accesses in raid5_wakeup_stripe_thread() and
__get_priority_stripe() on systems with non-contiguous NUMA node IDs.
alloc_thread_groups() sized the worker_groups array using
num_possible_nodes(), which returns the count of possible NUMA nodes.
However, the array is indexed by cpu_to_group(), which maps to
cpu_to_node() and returns the raw NUMA node ID.
On systems with non-contiguous NUMA node IDs (e.g. POWER9 with nodes 0
and 8), num_possible_nodes() returns 2 while cpu_to_node() can return 8,
causing an out-of-bounds access into conf->worker_groups.
Avoid the following crash when group_thread_cnt is set to any non-zero
value via sysfs:
BUG: Unable to handle kernel data access at 0x6f776b6f6f625f73
NIP: __list_add_valid+0x2c/0x100
LR: raid5_wakeup_stripe_thread+0x258/0x340 [raid456]
Call Trace:
raid5_wakeup_stripe_thread+0x258/0x340 [raid456]
raid5d+0x2a4/0x9c0 [raid456]
md_thread+0x108/0x280 [md_mod]
Use nr_node_ids (the highest possible node ID + 1) so that the array is
correctly sized for indexing by raw NUMA node ID.
Fixes: 851c30c9badf ("raid5: offload stripe handle to workqueue")
Cc: stable@vger.kernel.org
Reported-by: Patrick Bernier <patbernier@google.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/md/raid5.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index d52adf81065a..c7b4576b8f91 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7465,7 +7465,7 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt, int *group_cnt,
*worker_groups = NULL;
return 0;
}
- *group_cnt = num_possible_nodes();
+ *group_cnt = nr_node_ids;
size = sizeof(struct r5worker) * cnt;
workers = kcalloc(size, *group_cnt, GFP_NOIO);
*worker_groups = kzalloc_objs(struct r5worker_group, *group_cnt,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] md/raid5: Fix out-of-bounds access on non-contiguous NUMA nodes
2026-11-23 18:24 [PATCH] md/raid5: Fix out-of-bounds access on non-contiguous NUMA nodes Bart Van Assche
@ 2026-11-29 4:17 ` yu kuai
2026-11-29 23:21 ` Bart Van Assche
0 siblings, 1 reply; 3+ messages in thread
From: yu kuai @ 2026-11-29 4:17 UTC (permalink / raw)
To: Bart Van Assche, Song Liu, yu kuai
Cc: Li Nan, Xiao Ni, linux-raid, stable, Patrick Bernier
Hi,
在 2026/11/24 2:24, Bart Van Assche 写道:
> Prevent out-of-bounds array accesses in raid5_wakeup_stripe_thread() and
> __get_priority_stripe() on systems with non-contiguous NUMA node IDs.
> alloc_thread_groups() sized the worker_groups array using
> num_possible_nodes(), which returns the count of possible NUMA nodes.
> However, the array is indexed by cpu_to_group(), which maps to
> cpu_to_node() and returns the raw NUMA node ID.
>
> On systems with non-contiguous NUMA node IDs (e.g. POWER9 with nodes 0
> and 8), num_possible_nodes() returns 2 while cpu_to_node() can return 8,
> causing an out-of-bounds access into conf->worker_groups.
>
> Avoid the following crash when group_thread_cnt is set to any non-zero
> value via sysfs:
>
> BUG: Unable to handle kernel data access at 0x6f776b6f6f625f73
> NIP: __list_add_valid+0x2c/0x100
> LR: raid5_wakeup_stripe_thread+0x258/0x340 [raid456]
> Call Trace:
> raid5_wakeup_stripe_thread+0x258/0x340 [raid456]
> raid5d+0x2a4/0x9c0 [raid456]
> md_thread+0x108/0x280 [md_mod]
>
> Use nr_node_ids (the highest possible node ID + 1) so that the array is
> correctly sized for indexing by raw NUMA node ID.
>
> Fixes: 851c30c9badf ("raid5: offload stripe handle to workqueue")
> Cc: stable@vger.kernel.org
> Reported-by: Patrick Bernier <patbernier@google.com>
Since there is not report URL followed by Reported-by, this tag is removed.
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/md/raid5.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index d52adf81065a..c7b4576b8f91 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -7465,7 +7465,7 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt, int *group_cnt,
> *worker_groups = NULL;
> return 0;
> }
> - *group_cnt = num_possible_nodes();
> + *group_cnt = nr_node_ids;
> size = sizeof(struct r5worker) * cnt;
> workers = kcalloc(size, *group_cnt, GFP_NOIO);
> *worker_groups = kzalloc_objs(struct r5worker_group, *group_cnt,
--
Thanks,
Kuai
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] md/raid5: Fix out-of-bounds access on non-contiguous NUMA nodes
2026-11-29 4:17 ` yu kuai
@ 2026-11-29 23:21 ` Bart Van Assche
0 siblings, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2026-11-29 23:21 UTC (permalink / raw)
To: yukuai, Song Liu; +Cc: Li Nan, Xiao Ni, linux-raid, stable, Patrick Bernier
On 11/28/26 8:17 PM, yu kuai wrote:
> 在 2026/11/24 2:24, Bart Van Assche 写道:
>> Fixes: 851c30c9badf ("raid5: offload stripe handle to workqueue")
>> Cc: stable@vger.kernel.org
>> Reported-by: Patrick Bernier <patbernier@google.com>
>
> Since there is not report URL followed by Reported-by, this tag is removed.
Hi Kuai,
This issue was reported to me via private email. Hence no URL below
Reported-by. Do you agree that the reported deserves to be credited in
this case?
Thank you,
Bart.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-29 23:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 18:24 [PATCH] md/raid5: Fix out-of-bounds access on non-contiguous NUMA nodes Bart Van Assche
2026-11-29 4:17 ` yu kuai
2026-11-29 23:21 ` Bart Van Assche
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox