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]
Message-ID: <671b7f5aafdd41c5bc1f6b935dba23c0@AcuMS.aculab.com>
Date:   Sun, 30 Jul 2023 17:33:02 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Nathan Chancellor' <nathan@...nel.org>
CC:     'kernel test robot' <lkp@...el.com>,
        "'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>,
        "llvm@...ts.linux.dev" <llvm@...ts.linux.dev>,
        "oe-kbuild-all@...ts.linux.dev" <oe-kbuild-all@...ts.linux.dev>
Subject: RE: [PATCH next v2 2/5] minmax: Allow min()/max()/clamp() if the
 arguments have the same signedness.

From: Nathan Chancellor
> Sent: 30 July 2023 18:06
> 
> On Sun, Jul 30, 2023 at 02:55:50PM +0000, David Laight wrote:
> > From: kernel test robot
> > > Sent: 29 July 2023 03:01
> > >
> > > kernel test robot noticed the following build errors:
> > >
> > ...)
> > > compiler: clang version 15.0.7 (https://github.com/llvm/llvm-project.git
> > > 8dfdcc7b7bf66834a761bd8de445840ef68e4d1a)
> > > reproduce: (https://download.01.org/0day-ci/archive/20230729/202307290943.ODVeyeK6-
> > > lkp@...el.com/reproduce)
> > >
> > ...
> > > >> mm/percpu.c:3102:10: error: static assertion expression is not an integral constant expression
> > >                    base = min(ptr, base);
> > >                           ^~~~~~~~~~~~~~
> > ...                    ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >    include/linux/minmax.h:23:2: note: expanded from macro '__types_ok'
> > >            (is_signed_type(typeof(x)) == is_signed_type(typeof(y)))
> > >            ^
> > ...
> > >    mm/percpu.c:3102:10: note: cast that performs the conversions of a reinterpret_cast is not allowed
> > > in a constant expression
> >
> > That is a C++ error that seems to have crept into C.
> > The relevant definition is:
> >
> > #define is_signed_type(type)  (((type)(-1)) < (type)1)
> >
> > This seems to have been fixed in clang 16.0.0.
> 
> Indeed, it looks like
> 
> https://github.com/llvm/llvm-project/commit/a181de452df311d7647329120d05f4eb9c158b6c
> 
> fixed this as a result of the discussion at
> 
> https://github.com/llvm/llvm-project/issues/57687, which certainly makes
> sense.

Annoyingly it also isn't a 'proper' compile time constant for pointers.
Wrapping as:
	__builtin_choose_expr(__is_constexpr(is_signed(type(x)), is_signed_type(x), 0)
fixes it for old clang and is also needed to fix the >= 0 check in 5/5.

	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