[PATCH] md: protect read mddev->recovery in md_sync_action()

"Chen Cheng" <[email protected]>
Newsgroups gmane.linux.raid,gmane.linux.kernel
Message-ID <[email protected]>
From: Chen Cheng <[email protected]>

md_sync_action() read mddev->recovery in lockless path, use READ_ONCE()
instead of u64 plain read.

Fixes: e792a4c2156a3 ("md: add new helpers for sync_action")

Signed-off-by: Chen Cheng <[email protected]>
---
 drivers/md/md.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index c5c50640b684..f4415c1a79d9 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5074,11 +5074,11 @@ static enum sync_action md_get_active_sync_action(struct mddev *mddev)
 	return is_recover ? ACTION_RECOVER : ACTION_IDLE;
 }
 
 enum sync_action md_sync_action(struct mddev *mddev)
 {
-	unsigned long recovery = mddev->recovery;
+	unsigned long recovery = READ_ONCE(mddev->recovery);
 	enum sync_action active_action;
 
 	/*
 	 * frozen has the highest priority, means running sync_thread will be
 	 * stopped immediately, and no new sync_thread can start.
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.