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] [thread-next>] [day] [month] [year] [list]
Message-ID: <82a3eb7e-883c-a091-feec-27f3937491ab@toxicpanda.com>
Date:   Tue, 21 Jan 2020 09:00:35 -0500
From:   Josef Bacik <josef@...icpanda.com>
To:     Sun Ke <sunke32@...wei.com>, axboe@...nel.dk, mchristi@...hat.com
Cc:     linux-block@...r.kernel.org, nbd@...er.debian.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] nbd: add a flush_workqueue in nbd_start_device

On 1/21/20 7:48 AM, Sun Ke wrote:
> When kzalloc fail, may cause trying to destroy the
> workqueue from inside the workqueue.
> 
> If num_connections is m (2 < m), and NO.1 ~ NO.n
> (1 < n < m) kzalloc are successful. The NO.(n + 1)
> failed. Then, nbd_start_device will return ENOMEM
> to nbd_start_device_ioctl, and nbd_start_device_ioctl
> will return immediately without running flush_workqueue.
> However, we still have n recv threads. If nbd_release
> run first, recv threads may have to drop the last
> config_refs and try to destroy the workqueue from
> inside the workqueue.
> 
> To fix it, add a flush_workqueue in nbd_start_device.
> 
> Fixes: e9e006f5fcf2 ("nbd: fix max number of supported devs")
> Signed-off-by: Sun Ke <sunke32@...wei.com>
> ---
>   drivers/block/nbd.c | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index b4607dd96185..dd1f8c2c6169 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1264,7 +1264,12 @@ static int nbd_start_device(struct nbd_device *nbd)
>   
>   		args = kzalloc(sizeof(*args), GFP_KERNEL);
>   		if (!args) {
> -			sock_shutdown(nbd);
> +			if (i == 0)
> +				sock_shutdown(nbd);
> +			else {
> +				sock_shutdown(nbd);
> +				flush_workqueue(nbd->recv_workq);
> +			}

Just for readability sake why don't we just flush_workqueue() unconditionally, 
and add a comment so we know why in the future.  Thanks,

Josef

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ