Re: [PATCH] md: use RCU lock to protect traversal in md_spares_need_change()

From: Song Liu
Date: Tue Jan 30 2024 - 02:11:41 EST


On Thu, Jan 4, 2024 at 5:39 AM Li Lingfeng <lilingfeng@xxxxxxxxxxxxxxx> wrote:
>
> From: Li Lingfeng <lilingfeng3@xxxxxxxxxx>
>
> Since md_start_sync() will be called without the protect of mddev_lock,
> and it can run concurrently with array reconfiguration, traversal of rdev
> in it should be protected by RCU lock.
> Commit bc08041b32ab ("md: suspend array in md_start_sync() if array need
> reconfiguration") added md_spares_need_change() to md_start_sync(),
> casusing use of rdev without any protection.
> Fix this by adding RCU lock in md_spares_need_change().
>
> Fixes: bc08041b32ab ("md: suspend array in md_start_sync() if array need reconfiguration")
> Signed-off-by: Li Lingfeng <lilingfeng3@xxxxxxxxxx>

Looks good to me. Applied to md-tmp-6.9.

Thanks,
Song