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: <61eb467389f24216b77aaedb85006153@AcuMS.aculab.com>
Date: Mon, 30 Sep 2024 15:29:26 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Thomas Weißschuh' <linux@...ssschuh.net>, "Willy
 Tarreau" <w@....eu>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2] tools/nolibc: compiler: add macro __nolibc_fallthrough

From: Thomas Weißschuh
> Sent: 30 September 2024 06:35
> 
> 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.
> 
> Signed-off-by: Thomas Weißschuh <linux@...ssschuh.net>
> ---
> Changes in v2:
> - Add a do-while loop to improve compiler compatibility
> - Link to v1: https://lore.kernel.org/r/20240929-nolibc-fallthrough-v1-1-5ee07ea9a683@weissschuh.net
...
> 
> +#if __nolibc_has_attribute(fallthrough)
> +#  define __nolibc_fallthrough do { } while (0); __attribute__((fallthrough))
> +#else
> +#  define __nolibc_fallthrough do { } while (0)
> +#endif /* __nolibc_has_attribute(fallthrough) */
> +
>  #endif /* _NOLIBC_COMPILER_H */
> diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h
> index c968dbbc4ef8137e237b859bf18a6d2970230cbf..3892034198dd566d21a5cc0a9f67cf097d428393 100644
> --- a/tools/include/nolibc/stdio.h
> +++ b/tools/include/nolibc/stdio.h
> @@ -15,6 +15,7 @@
>  #include "stdarg.h"
>  #include "stdlib.h"
>  #include "string.h"
> +#include "compiler.h"
> 
>  #ifndef EOF
>  #define EOF (-1)
> @@ -264,7 +265,7 @@ int vfprintf(FILE *stream, const char *fmt, va_list args)
>  				case 'p':
>  					*(out++) = '0';
>  					*(out++) = 'x';
> -					/* fall through */
> +					__nolibc_fallthrough;
>  				default: /* 'x' and 'p' above */

Doesn't this break any old tools that would have parsed the /* fall though */
comment (or any of its variants)?

If you move the ; into the define the 'old' definition can be empty.
And then it is possible that:
				case x:
					xxxxx;
					/* fall though */
					__nolibc_fallthough
				case y:

will be processed correctly be all tools.
I know I had to lower the warning level for one of our kernel drivers.
But I've forgotten why - that code has to go through a lot of
compilers - including Microsofts.

	David


>  					u64toh_r(v, out);
>  					break;
> 
> ---
> base-commit: e7ed343658792771cf1b868df061661b7bcc5cef
> change-id: 20240929-nolibc-fallthrough-ba822a4a9255
> 
> Best regards,
> --
> Thomas Weißschuh <linux@...ssschuh.net>
> 

-
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