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]
Date:   Tue, 1 Jun 2021 15:14:02 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     Miquel Raynal <miquel.raynal@...tlin.com>
Cc:     Colin King <colin.king@...onical.com>,
        Richard Weinberger <richard@....at>,
        Vignesh Raghavendra <vigneshr@...com>,
        linux-mtd@...ts.infradead.org, kernel-janitors@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] mtd: rawnand: ensure return variable is initialized

On Thu, May 27, 2021 at 05:03:09PM +0200, Miquel Raynal wrote:
> Hi Colin,
> 
> Colin King <colin.king@...onical.com> wrote on Thu, 27 May 2021
> 15:50:48 +0100:
> 
> > From: Colin Ian King <colin.king@...onical.com>
> > 
> > Currently there are corner cases where spec_times is NULL and
> > chip->parameters.onfi or when best_mode is zero where ret is
> 
>                        ^
> something is missing here, the sentence is not clear
> 
> > not assigned a value and an uninitialized return value can be
> > returned. Fix this by ensuring ret is initialized to -EINVAL.
> 
> I don't see how this situation can happen.
> 
> In both cases, no matter the value of best_mode, the for loop will
> always execute at least one time (mode 0) so ret will be populated.
> 
> Maybe the robot does not know that best_mode cannot be negative and
> should be defined unsigned, but the current patch is invalid.
>

People think list counter unsigned is a good idea, but it's a terrible
idea and has caused hundreds of bugs for me to fix/report over the
years.  *grumble*.

Anyway, I was revisiting this code because it showed up as a Smatch
warning and the bug appears to be real.

	best_mode = fls(chip->parameters.onfi->sdr_timing_modes) - 1;

The "onfi->sdr_timing_modes" comes from the hardware in nand_onfi_detect()
and nothing checks that it is non-zero so "best_mode = fls(0) - 1;" is
negative and "ret" is uninitialized.

regards,
dan carpenter

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ