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:   Sat, 10 Jun 2023 22:29:21 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Andrew Morton' <akpm@...ux-foundation.org>,
        Lorenzo Stoakes <lstoakes@...il.com>
CC:     Lu Hongfei <luhongfei@...o.com>,
        Uladzislau Rezki <urezki@...il.com>,
        Christoph Hellwig <hch@...radead.org>,
        "open list:VMALLOC" <linux-mm@...ck.org>,
        open list <linux-kernel@...r.kernel.org>,
        "opensource.kernel@...o.com" <opensource.kernel@...o.com>
Subject: RE: [PATCH] mm/vmalloc: Replace the ternary conditional operator with
 min()

From: Andrew Morton <akpm@...ux-foundation.org>
> Sent: 10 June 2023 23:08
> 
> On Sat, 10 Jun 2023 22:06:35 +0100 Lorenzo Stoakes <lstoakes@...il.com> wrote:
> 
> > > > OK, as per the pedantic test bot, you'll need to change this to:-
> > > >
> > > > num = min_t(size_t, remains, PAGE_SIZE);
> 
> PAGE_SIZE is a nuisance.  It _usually_ creates the need for a
> cast:
> 
> hp2:/usr/src/linux-6.4-rc4> grep -r "min(.*PAGE_SIZE" . | wc -l
> 117
> hp2:/usr/src/linux-6.4-rc4> grep -r "min_t(.*PAGE_SIZE" . | wc -l
> 279
> 
> Perhaps it should always have been size_t.
> 
> I suppose we could do
> 
> #define PAGE_SIZE_T (size_t)PAGE_SIZE
> 
> And use that where needed.  Mainly because I like the name ;)

Or someone take my patches to relax the checks min() does a bit.
I think I last posted them in January.
Basically:
- unsigned v unsigned is always ok.
- signed v signed is always ok.
- unsigned v signed is ok provided one value is in [0..INT_MAX].
  this can be allowed for compile-time constants.

The usual 'error case' is unsigned v signed when the values
are known (by the person writing the code) to be non-negative.
Doing '(x) + 0u + 0ul + 0ull' zero extends the value without
ever masking it or 'accidentally' converting a pointer.

	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