lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPhsuW4P9t6fhAg5EFvTVkf3WLQy0=NTpZ-+1fcYBn3uyn9bng@mail.gmail.com>
Date:   Sat, 29 Jul 2023 18:44:48 +0800
From:   Song Liu <song@...nel.org>
To:     Yu Kuai <yukuai1@...weicloud.com>
Cc:     logang@...tatee.com, axboe@...nel.dk, linux-raid@...r.kernel.org,
        linux-kernel@...r.kernel.org, yukuai3@...wei.com,
        yi.zhang@...wei.com, yangerkun@...wei.com
Subject: Re: [PATCH -next v3] md/raid5-cache: fix a deadlock in r5l_exit_log()

On Sat, Jul 8, 2023 at 5:19 PM Yu Kuai <yukuai1@...weicloud.com> wrote:
>
> From: Yu Kuai <yukuai3@...wei.com>
>
> 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@...wei.com>

Applied to md-next. Thanks!

Song

> ---
>
> Changes in v3:
>  - Use a different solution.
>
>  drivers/md/raid5-cache.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c
> index 47ba7d9e81e1..2eac4a50d99b 100644
> --- a/drivers/md/raid5-cache.c
> +++ b/drivers/md/raid5-cache.c
> @@ -3168,12 +3168,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);
> --
> 2.39.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ