dm raid: protect md_stop() with 'reconfig_mutex'

[ Upstream commit 7d5fff8982 ]

__md_stop_writes() and __md_stop() will modify many fields that are
protected by 'reconfig_mutex', and all the callers will grab
'reconfig_mutex' except for md_stop().

Also, update md_stop() to make certain 'reconfig_mutex' is held using
lockdep_assert_held().

Fixes: 9d09e663d5 ("dm: raid456 basic support")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Yu Kuai 2023-07-08 17:21:53 +08:00 коммит произвёл Greg Kroah-Hartman
Родитель 0c4db5a04d
Коммит 4e1c1d7429
2 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -3305,8 +3305,8 @@ size_check:
return 0;
bad_unlock:
mddev_unlock(&rs->md);
md_stop(&rs->md);
mddev_unlock(&rs->md);
bad:
raid_set_free(rs);
@ -3317,7 +3317,9 @@ static void raid_dtr(struct dm_target *ti)
{
struct raid_set *rs = ti->private;
mddev_lock_nointr(&rs->md);
md_stop(&rs->md);
mddev_unlock(&rs->md);
raid_set_free(rs);
}

Просмотреть файл

@ -6281,6 +6281,8 @@ static void __md_stop(struct mddev *mddev)
void md_stop(struct mddev *mddev)
{
lockdep_assert_held(&mddev->reconfig_mutex);
/* stop the array and free an attached data structures.
* This is called from dm-raid
*/