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:   Thu, 15 Aug 2019 11:15:53 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Joe Perches <joe@...ches.com>
Cc:     hpa@...or.com, Peter Zijlstra <peterz@...radead.org>,
        Pavel Machek <pavel@....cz>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
        Borislav Petkov <bp@...en8.de>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>,
        "Gustavo A . R . Silva" <gustavo@...eddedor.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Kan Liang <kan.liang@...ux.intel.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Shawn Landden <shawn@....icu>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH] compiler_attributes.h: Add 'fallthrough' pseudo
 keyword for switch/case use

On Wed, Jul 31, 2019 at 01:02:07PM -0700, Kees Cook wrote:
> On Wed, Jul 31, 2019 at 08:48:32PM +0200, Peter Zijlstra wrote:
> > On Wed, Jul 31, 2019 at 11:24:36AM -0700, hpa@...or.com wrote:
> > > >> > +/*
> > > >> > + * Add the pseudo keyword 'fallthrough' so case statement blocks
> > > >> > + * must end with any of these keywords:
> > > >> > + *   break;
> > > >> > + *   fallthrough;
> > > >> > + *   goto <label>;
> > > >> > + *   return [expression];
> > > >> > + *
> > > >> > + *  gcc: >https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
> > > >> > + */
> > > >> > +#if __has_attribute(__fallthrough__)
> > > >> > +# define fallthrough                   __attribute__((__fallthrough__))
> > > >> > +#else
> > > >> > +# define fallthrough                    do {} while (0)  /* fallthrough */
> > > >> > +#endif
> > > >> > +
> > 
> > > If the comments are stripped, how would the compiler see them to be
> > > able to issue a warning? I would guess that it is retained or replaced
> > > with some other magic token.
> > 
> > Everything that has the warning (GCC-7+/CLANG-9) has that attribute.
> 
> I'd like to make sure we don't regress Coverity most of all. If the
> recent updates to the Coverity scanner include support for the attribute
> now, then I'm all for it. :)

I want to recant my position on Coverity coverage being a requirement
here. While I was originally concerned about suddenly adding thousands
more warnings to Coverity scans (if it doesn't support the flag --
I should know soon), it's been made clear to me we're now at the point
where this is about to happen for Clang instead (since _it_ doesn't
support the comment-style marking and never will but is about to gain
C support[1] for the detection -- it only had C++ before).

With that out of the way, yes, let's do a mass conversion. As mentioned
before, I think "fallthrough;" should be used here (to match "break;").
Let's fork the C language. :)

-Kees

[1] https://reviews.llvm.org/D64838

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ