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: <20190819035337.GB3086@ming.t460p>
Date:   Mon, 19 Aug 2019 11:53:38 +0800
From:   Ming Lei <ming.lei@...hat.com>
To:     Pan Bian <bianpan2016@....com>
Cc:     Jens Axboe <axboe@...nel.dk>, linux-block@...r.kernel.org,
        linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH V2] block: fix a mismatched alloc free in bio_alloc_bioset

On Mon, Aug 19, 2019 at 08:55:20AM +0800, Pan Bian wrote:
> The function kmalloc is called to allocate memory if bs is NULL.
> However, mempool_free is used to release the memory chunk even if bs is
> NULL in the error hanlding code. This patch checks bs and use the
> correct function to release memory.
> 
> 
> Fixes: 3f86a82aeb ("block: Consolidate bio_alloc_bioset(), bio_kmalloc()")
> Signed-off-by: Pan Bian <bianpan2016@....com>
> Cc: stable@...r.kernel.org
> ---
> V2: add Fixes and Cc tags
> ---
>  block/bio.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/block/bio.c b/block/bio.c
> index 299a0e7..c5f5238 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -515,7 +515,10 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
>  	return bio;
>  
>  err_free:
> -	mempool_free(p, &bs->bio_pool);
> +	if (!bs)
> +		kfree(p);
> +	else
> +		mempool_free(p, &bs->bio_pool);
>  	return NULL;
>  }
>  EXPORT_SYMBOL(bio_alloc_bioset);

'err_free' is only reached in case that 'bs' isn't NULL, so this patch
fixes nothing.


Thanks,
Ming

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ