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: <c7818967-1fea-45da-9713-20de4bcb1c44@suse.de>
Date:   Wed, 20 Sep 2023 16:06:56 +0200
From:   Hannes Reinecke <hare@...e.de>
To:     Fedor Pchelkin <pchelkin@...ras.ru>,
        Mike Snitzer <snitzer@...nel.org>
Cc:     Alasdair Kergon <agk@...hat.com>, dm-devel@...hat.com,
        linux-kernel@...r.kernel.org,
        Alexey Khoroshilov <khoroshilov@...ras.ru>,
        lvc-project@...uxtesting.org, stable@...r.kernel.org
Subject: Re: [PATCH] dm-zoned: free dmz->ddev array in dmz_put_zoned_device

On 9/20/23 12:51, Fedor Pchelkin wrote:
> Commit 4dba12881f88 ("dm zoned: support arbitrary number of devices")
> made the pointers to additional zoned devices to be stored in a
> dynamically allocated dmz->ddev array. However, this array is not freed.
> 
> Free it when cleaning up zoned device information inside
> dmz_put_zoned_device(). Assigning NULL to dmz->ddev elements doesn't make
> sense there as they are not supposed to be reused later and the whole dmz
> target structure is being cleaned anyway.
> 
> Found by Linux Verification Center (linuxtesting.org).
> 
> Fixes: 4dba12881f88 ("dm zoned: support arbitrary number of devices")
> Cc: stable@...r.kernel.org
> Signed-off-by: Fedor Pchelkin <pchelkin@...ras.ru>
> ---
>   drivers/md/dm-zoned-target.c | 8 +++-----
>   1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/md/dm-zoned-target.c b/drivers/md/dm-zoned-target.c
> index ad8e670a2f9b..e25cd9db6275 100644
> --- a/drivers/md/dm-zoned-target.c
> +++ b/drivers/md/dm-zoned-target.c
> @@ -753,12 +753,10 @@ static void dmz_put_zoned_device(struct dm_target *ti)
>   	struct dmz_target *dmz = ti->private;
>   	int i;
>   
> -	for (i = 0; i < dmz->nr_ddevs; i++) {
> -		if (dmz->ddev[i]) {
> +	for (i = 0; i < dmz->nr_ddevs; i++)
> +		if (dmz->ddev[i])
>   			dm_put_device(ti, dmz->ddev[i]);
> -			dmz->ddev[i] = NULL;
> -		}
> -	}
> +	kfree(dmz->ddev);
>   }
>   
>   static int dmz_fixup_devices(struct dm_target *ti)

Hmm. I'm not that happy with it; dmz_put_zoned_device() is using 
dm_target as an argument, whereas all of the functions surrounding the 
call sites is using the dmz_target directly.

Mind to modify the function to use 'struct dmz_target' as an argument?

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@...e.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ