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]
Date:   Sat, 20 Jun 2020 22:17:20 +0800
From:   Coly Li <colyli@...e.de>
To:     "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc:     Kent Overstreet <kent.overstreet@...il.com>,
        linux-bcache@...r.kernel.org, linux-kernel@...r.kernel.org,
        "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Subject: Re: [PATCH][next] bcache: movinggc: Use struct_size() helper in
 kzalloc()

On 2020/6/18 06:33, Gustavo A. R. Silva wrote:
> Make use of the struct_size() helper instead of an open-coded version
> in order to avoid any potential type mistakes.
> 
> This code was detected with the help of Coccinelle and, audited and
> fixed manually.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>

The patch looks good to me, and I assume you already test and verify the
change. I will add them in my for-test directory.

Thanks.

Coly Li

> ---
>  drivers/md/bcache/movinggc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
> index 7891fb512736..b7dd2d75f58c 100644
> --- a/drivers/md/bcache/movinggc.c
> +++ b/drivers/md/bcache/movinggc.c
> @@ -145,8 +145,8 @@ static void read_moving(struct cache_set *c)
>  			continue;
>  		}
>  
> -		io = kzalloc(sizeof(struct moving_io) + sizeof(struct bio_vec)
> -			     * DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS),
> +		io = kzalloc(struct_size(io, bio.bio.bi_inline_vecs,
> +					 DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS)),
>  			     GFP_KERNEL);
>  		if (!io)
>  			goto err;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ