Patch "md/raid5-cache: fix a deadlock in r5l_exit_log()" has been added to the 6.1-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    md/raid5-cache: fix a deadlock in r5l_exit_log()

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     md-raid5-cache-fix-a-deadlock-in-r5l_exit_log.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit d71530f1a97fc80d9a5f05e54b9799720b4ea651
Author: Yu Kuai <yukuai3@xxxxxxxxxx>
Date:   Sat Jul 8 17:17:27 2023 +0800

    md/raid5-cache: fix a deadlock in r5l_exit_log()
    
    [ Upstream commit a705b11b358dee677aad80630e7608b2d5f56691 ]
    
    Commit b13015af94cf ("md/raid5-cache: Clear conf->log after finishing
    work") introduce a new problem:
    
    // caller hold reconfig_mutex
    r5l_exit_log
     flush_work(&log->disable_writeback_work)
                            r5c_disable_writeback_async
                             wait_event
                              /*
                               * conf->log is not NULL, and mddev_trylock()
                               * will fail, wait_event() can never pass.
                               */
     conf->log = NULL
    
    Fix this problem by setting 'config->log' to NULL before wake_up() as it
    used to be, so that wait_event() from r5c_disable_writeback_async() can
    exist. In the meantime, move forward md_unregister_thread() so that
    null-ptr-deref this commit fixed can still be fixed.
    
    Fixes: b13015af94cf ("md/raid5-cache: Clear conf->log after finishing work")
    Signed-off-by: Yu Kuai <yukuai3@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230708091727.1417894-1-yukuai1@xxxxxxxxxxxxxxx
    Signed-off-by: Song Liu <song@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
index 832d8566e1656..477e3ae17545a 100644
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@ -3166,12 +3166,15 @@ void r5l_exit_log(struct r5conf *conf)
 {
 	struct r5l_log *log = conf->log;
 
-	/* Ensure disable_writeback_work wakes up and exits */
-	wake_up(&conf->mddev->sb_wait);
-	flush_work(&log->disable_writeback_work);
 	md_unregister_thread(&log->reclaim_thread);
 
+	/*
+	 * 'reconfig_mutex' is held by caller, set 'confg->log' to NULL to
+	 * ensure disable_writeback_work wakes up and exits.
+	 */
 	conf->log = NULL;
+	wake_up(&conf->mddev->sb_wait);
+	flush_work(&log->disable_writeback_work);
 
 	mempool_exit(&log->meta_pool);
 	bioset_exit(&log->bs);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux