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:   Tue, 13 Dec 2022 11:50:04 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Jiri Slaby' <jirislaby@...nel.org>, 'Tejun Heo' <tj@...nel.org>
CC:     Christoph Hellwig <hch@...radead.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Martin Liska <mliska@...e.cz>,
        Josef Bacik <josef@...icpanda.com>,
        Jens Axboe <axboe@...nel.dk>,
        "cgroups@...r.kernel.org" <cgroups@...r.kernel.org>,
        "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>
Subject: RE: [PATCH] block/blk-iocost (gcc13): cast enum members to int in
 prints

From: Jiri Slaby
> Sent: 13 December 2022 11:15
> 
> On 13. 12. 22, 9:30, David Laight wrote:
> > From: Tejun Heo <htejun@...il.com> On Behalf Of 'Tejun Heo'
> >> Sent: 12 December 2022 21:47
> >> To: Jiri Slaby <jirislaby@...nel.org>
> >> Cc: David Laight <David.Laight@...LAB.COM>; Christoph Hellwig <hch@...radead.org>; linux-
> >> kernel@...r.kernel.org; Martin Liska <mliska@...e.cz>; Josef Bacik <josef@...icpanda.com>; Jens
> Axboe
> >> <axboe@...nel.dk>; cgroups@...r.kernel.org; linux-block@...r.kernel.org
> >> Subject: Re: [PATCH] block/blk-iocost (gcc13): cast enum members to int in prints
> >>
> >> On Mon, Dec 12, 2022 at 01:14:31PM +0100, Jiri Slaby wrote:
> >>>> If so, my suggestion is just sticking with the old behavior until we switch
> >>>> to --std=g2x and then make one time adjustment at that point.
> >>>
> >>> So is the enum split OK under these circumstances?
> >>
> >> Oh man, it's kinda crazy that the compiler is changing in a way that the
> >> same piece of code can't be compiled the same way across two adjoining
> >> versions of the same compiler. But, yeah, if that's what gcc is gonna do and
> >> splitting enums is the only way to be okay across the compiler versions,
> >> there isn't any other choice we can make.
> >
> > It is also a silent code-breaker.
> > Compile this for 32bit x86:
> >
> > enum { a = 1, b = ~0ull};
> 
> But having ull in an enum is undefined anyway. C99 allows only int
> constants. gnuC supports ulong expressions (IIRC).

gcc supports 'long long' as well - 64bit on 32bit systems.

In practical terms it really doesn't matter what C99 (or any other
version) says, the important thing is that the compiler accepted it.

> > extern int foo(int, ...);
> > int f(void)
> > {
> >      return foo(0, a, 2);
> > }
> >
> > gcc13 pushes an extra zero onto the stack between the 1 and 2.
> 
> So this is sort of "expected".

For some definitions of "expected" :-)

Note that it (probably) makes no actual difference to some architectures
(like 64bit x86) where all varargs parameters are passed as 64bit.
Extending a value to 64bits just makes the high bits well defined.
(The high bits of stacked 32bit args are undefined.)

	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