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: <2E89032DDAA8B9408CB92943514A0337014C1D771E@SW-EX-MBX01.diasemi.com>
Date:   Fri, 9 Mar 2018 11:36:04 +0000
From:   Adam Thomson <Adam.Thomson.Opensource@...semi.com>
To:     "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
        Support Opensource <Support.Opensource@...semi.com>,
        Sebastian Reichel <sre@...nel.org>
CC:     "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kernel-hardening@...ts.openwall.com" 
        <kernel-hardening@...ts.openwall.com>,
        Kees Cook <keescook@...omium.org>,
        "Gustavo A. R. Silva" <garsilva@...eddedor.com>
Subject: RE: [PATCH] power: supply: da9150-fg: remove VLA usage

On 09 March 2018 04:58, Gustavo A. R. Silva wrote:

> In preparation to enabling -Wvla, remove VLA usage and replace it
> with fixed-length arrays.
> 
> It seems that the length of array 'buf' will not exceed
> DA9150_QIF_SHORT_SIZE bytes (2 bytes). But a fixed length
> of DA9150_QIF_BYTE_SIZE bytes (8 bytes) was chosen in case
> this change in the future.
> 
> Fixed as part of the directive to remove all VLAs from
> the kernel: https://lkml.org/lkml/2018/3/7/621
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@...eddedor.com>
> ---
>  drivers/power/supply/da9150-fg.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/power/supply/da9150-fg.c b/drivers/power/supply/da9150-fg.c
> index 8b8ce97..96893be 100644
> --- a/drivers/power/supply/da9150-fg.c
> +++ b/drivers/power/supply/da9150-fg.c
> @@ -92,7 +92,7 @@ struct da9150_fg {
>  static u32 da9150_fg_read_attr(struct da9150_fg *fg, u8 code, u8 size)
> 
>  {
> -	u8 buf[size];
> +	u8 buf[DA9150_QIF_BYTE_SIZE];

You can use DA9150_QIF_LONG_SIZE as that's the biggest size of an attribute
which can be accessed. This will also save a little space.

>  	u8 read_addr;
>  	u32 res = 0;
>  	int i;
> @@ -111,7 +111,7 @@ static void da9150_fg_write_attr(struct da9150_fg *fg, u8
> code, u8 size,
>  				 u32 val)
> 
>  {
> -	u8 buf[size];
> +	u8 buf[DA9150_QIF_BYTE_SIZE];
>  	u8 write_addr;
>  	int i;
> 
> --
> 2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ