]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
md: protect md_unregister_thread from reentrancy
authorGuoqing Jiang <guoqing.jiang@cloud.ionos.com>
Fri, 29 Apr 2022 08:49:09 +0000 (16:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2022 14:52:40 +0000 (16:52 +0200)
commitac8fd53fa022d57b16393e8cc3ab2f80ad315d4a
treeebc4c7d627e5d532811d057be80496d356dfabdf
parent6ae96e638739f040959610d44c0a696d6a80542f
md: protect md_unregister_thread from reentrancy

[ Upstream commit 1e267742283a4b5a8ca65755c44166be27e9aa0f ]

Generally, the md_unregister_thread is called with reconfig_mutex, but
raid_message in dm-raid doesn't hold reconfig_mutex to unregister thread,
so md_unregister_thread can be called simulitaneously from two call sites
in theory.

Then after previous commit which remove the protection of reconfig_mutex
for md_unregister_thread completely, the potential issue could be worse
than before.

Let's take pers_lock at the beginning of function to ensure reentrancy.

Reported-by: Donald Buczek <buczek@molgen.mpg.de>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/md.c