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: <b5dcc85d-f709-a3a3-e7ad-9c71f278842a@kernel.org>
Date:   Tue, 5 Sep 2023 14:04:00 +0900
From:   Damien Le Moal <dlemoal@...nel.org>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        linux-ide@...r.kernel.org
Subject: Re: [PATCH] ata: sata_mv: Fix incorrect string length computation in
 mv_dump_mem()

On 9/5/23 04:54, Christophe JAILLET wrote:
> snprintf() returns the "number of characters which *would* be generated for
> the given input", not the size *really* generated.
> 
> In order to avoid too large values for 'o' (and potential negative values
> for "sizeof(linebuf) o") use scnprintf() instead of snprintf().
> 
> Note that given the "w < 4" in the for loop, the buffer can NOT
> overflow, but using the *right* function is always better.
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>

Doesn't this need Fixes and CC stable tags ?

> ---
>  drivers/ata/sata_mv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index d105db5c7d81..45e48d653c60 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -1255,8 +1255,8 @@ static void mv_dump_mem(struct device *dev, void __iomem *start, unsigned bytes)
>  
>  	for (b = 0; b < bytes; ) {
>  		for (w = 0, o = 0; b < bytes && w < 4; w++) {
> -			o += snprintf(linebuf + o, sizeof(linebuf) - o,
> -				      "%08x ", readl(start + b));
> +			o += scnprintf(linebuf + o, sizeof(linebuf) - o,
> +				       "%08x ", readl(start + b));
>  			b += sizeof(u32);
>  		}
>  		dev_dbg(dev, "%s: %p: %s\n",

-- 
Damien Le Moal
Western Digital Research

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ