]> git.baikalelectronics.ru Git - kernel.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 16:36:22 +0000 (18:36 +0200)
commita8ea29134ff917238fc2b8873c1ff3bdcdd3fbc4
tree57d802c21095e751351a1c31698dd42e3cd8b161
parent90c8e6d14bc1e01fe5cd04f35633248ca9c3a270
md: protect md_unregister_thread from reentrancy

[ Upstream commit 19376e422df3b0aff2e5abf1845048bbef79a1c9 ]

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