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] [day] [month] [year] [list]
Message-ID: <956f34ffd3b0430183e66083a76c706b@AcuMS.aculab.com>
Date:   Sun, 15 Oct 2023 09:30:50 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Alexey Dobriyan' <adobriyan@...il.com>
CC:     "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Al Viro <viro@...iv.linux.org.uk>
Subject: RE: [PATCH] fs: move and constify sysctl_nr_open_min,
 sysctl_nr_open_max

From: Alexey Dobriyan
> Sent: 14 October 2023 10:23
> 
> On Thu, Oct 12, 2023 at 01:54:06PM +0000, David Laight wrote:
> > From: Alexey Dobriyan
> > > Sent: 11 October 2023 19:24
> 
> > > +/* our min() is unusable in constant expressions ;-/ */
> > > +#define __const_min(x, y) ((x) < (y) ? (x) : (y))
> > > +static const unsigned int sysctl_nr_open_max =
> > > +	__const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG;
> >
> > I think you'll find that min() is fine.
> 
> Mainline min() still can't do
> 
> 	static const x = min(1, 2);

(second reply having realised what actually fails.)

That is ok.

The code actually falls foul of the type check.
The LHS will be 'signed int' and the RHS 'size_t' which IIRC is
'unsigned int' on 32 bit and 'unsigned long' on 64 bit.

So the comment is explaining the wrong error.
Changing to (size_t)INT_MAX should make min() work.

My new version should let that through, it allows unsigned
against non-negative signed constants.

	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