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: <79p0n5po-1377-4q33-3599-6129o38p96p@fhfr.qr>
Date:   Tue, 5 Apr 2022 14:53:18 +0200 (CEST)
From:   Richard Biener <rguenther@...e.de>
To:     Michael Matz <matz@...e.de>
cc:     Peter Zijlstra <peterz@...radead.org>,
        Borislav Petkov <bp@...en8.de>,
        linux-toolchains@...r.kernel.org,
        lkml <linux-kernel@...r.kernel.org>
Subject: Re: older gccs and case labels producing integer constants

On Tue, 5 Apr 2022, Michael Matz wrote:

> Hey,
> 
> On Tue, 5 Apr 2022, Peter Zijlstra wrote:
> 
> > > sound/usb/midi.c: In function ‘snd_usbmidi_out_endpoint_create’:
> > > sound/usb/midi.c:1389:2: error: case label does not reduce to an integer constant
> > >   case (((0xfc08) << 16) | (0x0101)):
> > >   ^~~~
> > 
> > IIRC GCC-8 fixed a bunch of -wrapv issues. Could be this is one of them 
> > I suppose.
> 
> Or better said, later GCCs returned back to the old behaviour of rejecting 
> this only with -pedantic even in the presence of -fsanitize.

Only that it doesn't:

#define USB_ID(v,p) (((v)<<16)|(p))
void foo (unsigned int *i)
{
  switch (*i)
    {
      case USB_ID(0xfc08, 0x0101):;
    }
}

> gcc-11 -S t.c -std=c99 -fsanitize=shift
t.c: In function 'foo':
t.c:6:7: error: case label does not reduce to an integer constant
    6 |       case USB_ID(0xfc08, 0x0101):;
      |       ^~~~

for some reason it might fail to sanitize the case label for the
full testcase but clearly it doesn't so on purpose.

> But 
> pedantically speaking (ahem!) it really isn't conforming c99 (which the 
> compilation flags claim) , and in this case it seems easy enough to make 
> the construct actually be conforming in the kernel sources, so that should 
> perhaps be done?

Indeed.  Simply cast vendor/product to (unsigned) in the USB_ID
macro to avoid arithmetic shifts.

Richard.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ