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:   Thu, 21 Feb 2019 11:54:26 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     "Luis R. Rodriguez" <mcgrof@...nel.org>,
        Randy Dunlap <rdunlap@...radead.org>,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH 2/2] test_firmware: silence underflow warning in
 test_dev_config_update_u8()

On Thu, 21 Feb 2019 22:18:56 +0300 Dan Carpenter <dan.carpenter@...cle.com> wrote:

> On Thu, Feb 21, 2019 at 10:54:58AM -0800, Andrew Morton wrote:
> > On Thu, 21 Feb 2019 21:38:26 +0300 Dan Carpenter <dan.carpenter@...cle.com> wrote:
> > 
> > > We put an upper bound on "new" but we don't check for negatives.
> > 
> > U8_MAX has unsigned type, so `if (new > U8_MAX)' does check for negative.
> > 
> 
> No, doesn't work in this case.
> 
> #define U8_MAX          ((u8)~0U)
> 
> It would need to unsigned long for the type promotion to prevent
> negatives, but it starts as unsigned int, then unsigned char, which is
> type promoted to int.

OK.

> It would be more clear to just write it as:
> 
> #define U8_MAX 0xff

That doesn't work either.  Tricky.


#include <stdio.h>

typedef unsigned char u8;

#define U8_MAX 0xff

int main(int argc, char *argv[])
{
	long new;

	new = -20;

	if (new > U8_MAX)
		printf("over\n");
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ