* [PATCH] md/raid10: fix null ptr dereference in raid10_size()
@ 2024-10-09 1:49 Yu Kuai
2024-10-09 7:36 ` Christoph Hellwig
2024-10-17 22:26 ` Song Liu
0 siblings, 2 replies; 3+ messages in thread
From: Yu Kuai @ 2024-10-09 1:49 UTC (permalink / raw)
To: song, hch
Cc: iam, linux-raid, linux-kernel, yukuai3, yukuai1, yi.zhang, yangerkun
From: Yu Kuai <yukuai3@huawei.com>
In raid10_run() if raid10_set_queue_limits() succeed, the return value
is set to zero, and if following procedures failed raid10_run() will
return zero while mddev->private is still NULL, causing null ptr
dereference in raid10_size().
Fix the problem by only overwrite the return value if
raid10_set_queue_limits() failed.
Fixes: 3d8466ba68d4 ("md/raid10: use the atomic queue limit update APIs")
Reported-and-tested-by: ValdikSS <iam@valdikss.org.ru>
Closes: https://lore.kernel.org/all/0dd96820-fe52-4841-bc58-dbf14d6bfcc8@valdikss.org.ru/
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/raid10.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index f3bf1116794a..862b1fb71d86 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -4061,9 +4061,12 @@ static int raid10_run(struct mddev *mddev)
}
if (!mddev_is_dm(conf->mddev)) {
- ret = raid10_set_queue_limits(mddev);
- if (ret)
+ int err = raid10_set_queue_limits(mddev);
+
+ if (err) {
+ ret = err;
goto out_free_conf;
+ }
}
/* need to check that every block has at least one working mirror */
--
2.39.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] md/raid10: fix null ptr dereference in raid10_size()
2024-10-09 1:49 [PATCH] md/raid10: fix null ptr dereference in raid10_size() Yu Kuai
@ 2024-10-09 7:36 ` Christoph Hellwig
2024-10-17 22:26 ` Song Liu
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2024-10-09 7:36 UTC (permalink / raw)
To: Yu Kuai
Cc: song, hch, iam, linux-raid, linux-kernel, yukuai3, yi.zhang, yangerkun
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] md/raid10: fix null ptr dereference in raid10_size()
2024-10-09 1:49 [PATCH] md/raid10: fix null ptr dereference in raid10_size() Yu Kuai
2024-10-09 7:36 ` Christoph Hellwig
@ 2024-10-17 22:26 ` Song Liu
1 sibling, 0 replies; 3+ messages in thread
From: Song Liu @ 2024-10-17 22:26 UTC (permalink / raw)
To: Yu Kuai; +Cc: hch, iam, linux-raid, linux-kernel, yukuai3, yi.zhang, yangerkun
On Tue, Oct 8, 2024 at 6:51 PM Yu Kuai <yukuai1@huaweicloud.com> wrote:
>
> From: Yu Kuai <yukuai3@huawei.com>
>
> In raid10_run() if raid10_set_queue_limits() succeed, the return value
> is set to zero, and if following procedures failed raid10_run() will
> return zero while mddev->private is still NULL, causing null ptr
> dereference in raid10_size().
>
> Fix the problem by only overwrite the return value if
> raid10_set_queue_limits() failed.
>
> Fixes: 3d8466ba68d4 ("md/raid10: use the atomic queue limit update APIs")
> Reported-and-tested-by: ValdikSS <iam@valdikss.org.ru>
> Closes: https://lore.kernel.org/all/0dd96820-fe52-4841-bc58-dbf14d6bfcc8@valdikss.org.ru/
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Applied to md-6.12.
Thanks for the fix!
Song
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-17 22:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-09 1:49 [PATCH] md/raid10: fix null ptr dereference in raid10_size() Yu Kuai
2024-10-09 7:36 ` Christoph Hellwig
2024-10-17 22:26 ` Song Liu
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®