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]
Message-ID: <20240930033357.GA13730@1wt.eu>
Date: Mon, 30 Sep 2024 05:33:57 +0200
From: Willy Tarreau <w@....eu>
To: Thomas Weißschuh <linux@...ssschuh.net>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tools/nolibc: compiler: add macro __nolibc_fallthrough

Hi Thomas,

On Sun, Sep 29, 2024 at 11:49:57PM +0200, Thomas Weißschuh wrote:
> Recent version of GCC and clang gained -Wimplicit-fallthrough,
> warning about implicit fall-through between switch labels.
> As nolibc does not control the compilation flags, this can trigger
> warnings for when built by the user.
> Make use of the "fallthrough" attribute to explicitly annotate the
> expected fall-throughs and silence the warning.

Good idea!

> +#if __nolibc_has_attribute(fallthrough)
> +#  define __nolibc_fallthrough __attribute__((fallthrough))
> +#else
> +#  define __nolibc_fallthrough
> +#endif /* __nolibc_has_attribute(fallthrough) */

In haproxy we're prepending a "do { } while (0)" statement at the
beginning of the macro, first to make sure to have a statement for
the case where it's not supported, and because gcc-7 will emit a
warning if placed after a label (and clang will even error in this
case). I'm covering all known cases with the following:

  #if __has_attribute(fallthrough)
  #  define __fallthrough do { } while (0); __attribute__((fallthrough))
  #else
  #  define __fallthrough do { } while (0)
  #endif

I think you should do the same here since, as you mentioned, we have
no control over the user's toolchain.

Thanks,
Willy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ