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: <CAD=FV=VTXdXX=8E_NcS=5mcWFJWdrLEpXKbyk4F2xE02FyOJ5Q@mail.gmail.com>
Date:   Wed, 2 Aug 2017 15:54:32 -0700
From:   Doug Anderson <dianders@...omium.org>
To:     Matthias Kaehlcke <mka@...omium.org>
Cc:     Minchan Kim <minchan@...nel.org>, Nitin Gupta <ngupta@...are.org>,
        Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] zram: Fix buffer size passed to strlcpy()

Hi,

On Fri, Jul 28, 2017 at 10:12 AM, Matthias Kaehlcke <mka@...omium.org> wrote:
> comp_algorithm_store() passes the size of the source buffer to strlcpy()
> instead of the destination buffer size, fix this.

This was introduced in commit 415403be37e2 ("zram: use crypto api to
check alg availability"), but probably don't need a "Fixes" since
there's not really a bug (see below)

> Signed-off-by: Matthias Kaehlcke <mka@...omium.org>
> ---
>  drivers/block/zram/zram_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 856d5dc02451..7d2ddffad361 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -327,7 +327,7 @@ static ssize_t comp_algorithm_store(struct device *dev,
>                 return -EBUSY;
>         }
>
> -       strlcpy(zram->compressor, compressor, sizeof(compressor));
> +       strlcpy(zram->compressor, compressor, sizeof(zram->compressor));

As far as I can tell the two sizes are identical.  In struct zram:

char compressor[CRYPTO_MAX_ALG_NAME];

Locally here:

char compressor[CRYPTO_MAX_ALG_NAME];

...so there is no bug per say unless there's a hidden "#undef".
...but your change does make it a little clearer, plus if someone ever
changed one of these arrays it would be safer.  Thus:

Reviewed-by: Douglas Anderson <dianders@...omium.org>


I suppose another option would be to define the local array based on
the size of the structure.  AKA locally in the function:

  char compressor[ARRAY_SIZE(zram->compressor)];

...if you did that you could replace the strlcpy() below with a simple
strcpy() since you'd be guaranteed that there's be enough space.
...but I'm probably overthinking it too much. ;-P


-Doug

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ