]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request
authorLi Nan <linan122@huawei.com>
Sat, 27 May 2023 07:22:15 +0000 (15:22 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jul 2023 06:37:05 +0000 (08:37 +0200)
commit45fa023b3334a7ae6f6c4eb977295804222dfa28
tree2fd75c1d6f949f614f0381872397f6aa5a5a02df
parent31c805a44b7569ca1017a4714385182d98bba212
md/raid10: fix null-ptr-deref of mreplace in raid10_sync_request

[ Upstream commit 34817a2441747b48e444cb0e05d84e14bc9443da ]

There are two check of 'mreplace' in raid10_sync_request(). In the first
check, 'need_replace' will be set and 'mreplace' will be used later if
no-Faulty 'mreplace' exists, In the second check, 'mreplace' will be
set to NULL if it is Faulty, but 'need_replace' will not be changed
accordingly. null-ptr-deref occurs if Faulty is set between two check.

Fix it by merging two checks into one. And replace 'need_replace' with
'mreplace' because their values are always the same.

Fixes: ee37d7314a32 ("md/raid10: Fix raid10 replace hang when new added disk faulty")
Signed-off-by: Li Nan <linan122@huawei.com>
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Song Liu <song@kernel.org>
Link: https://lore.kernel.org/r/20230527072218.2365857-2-linan666@huaweicloud.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/raid10.c