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]
Date:   Tue, 1 Nov 2022 09:39:22 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     "'Jiri Slaby (SUSE)'" <jirislaby@...nel.org>,
        "Jason@...c4.com" <Jason@...c4.com>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "Martin Liska" <mliska@...e.cz>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        "wireguard@...ts.zx2c4.com" <wireguard@...ts.zx2c4.com>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: RE: [PATCH] wireguard (gcc13): cast enum limits members to int in
 prints

From: Jiri Slaby (SUSE)
> Sent: 31 October 2022 11:44
> 
> Since gcc13, each member of an enum has the same type as the enum [1]. And
> that is inherited from its members. Provided "REKEY_AFTER_MESSAGES = 1ULL
> << 60", the named type is unsigned long.
> 
> This generates warnings with gcc-13:
>   error: format '%d' expects argument of type 'int', but argument 6 has type 'long unsigned int'
> 
> Cast the enum members to int when printing them.
> 
> Alternatively, we can cast it to ulong (to silence gcc < 12) and use %lu.
> Alternatively, we can move REKEY_AFTER_MESSAGES away from the enum.

I'd suggest moving the 'out of range' value out of the enum.
Otherwise integer promotion to 'long' might happen elsewhere
and the effects might not be desirable.

It is a shame that gcc doesn't force you to add the type
to 'big enums' (or emit a warning) so that the behavioural
change is properly detected.

>From reading the gcc bug it seems that C++ has a syntax for that.

	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