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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 14 Aug 2023 08:04:53 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Linus Torvalds' <torvalds@...ux-foundation.org>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Andy Shevchenko" <andriy.shevchenko@...ux.intel.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        "Matthew Wilcox (Oracle)" <willy@...radead.org>,
        Christoph Hellwig <hch@...radead.org>,
        "Jason A. Donenfeld" <Jason@...c4.com>
Subject: RE: [PATCH v3 5/5] minmax: Relax check to allow comparison between
 int and small unsigned constants.

From: Linus Torvalds
> Sent: 10 August 2023 20:47
> 
> On Thu, 10 Aug 2023 at 01:29, David Laight <David.Laight@...lab.com> wrote:
> >
> > > Does that expression mean "give me a number 0..20" or "MININT..20"?
> >
> > Why does the lower bound of any type matter?
> 
> Because it might actually be the upper bound.
> 
> That MININT becomes be 20 if it's unsigned, and you do min() on it.
> 
> Bugs when mixing unsigned and signed comparisons is WHY WE HAVE THE
> TYPE CHECK IN THE FIRST PLACE.

Have you considered patches 1 to 3 and maybe 4?
These still disallow signed v unsigned compares but don't worry
about the actual types involved.

All your objections seen to be to patch 5.

> And no, constants don't necessarily make that any different.
> 
> I think we all agree that using a (signed) constant 20 makes perfect
> sense when the other side is an unsigned entity. It may be "signed",
> but when the value is positive, we don't care.
> 
> But using an *unsigned* constant 20 when the other side is signed
> means that now somebody is confused. We should warn.

In that case maybe I can add an is_signed() check into the constant
test.
The will allow min(unsigned_var, 20) but disallow min(signed_var, 20u).

I might simplify things by limiting the checks on the 'backwards'
compare of min(constant, variable).
(They almost need a warning...)

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ