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: <1466775784.1847.60.camel@perches.com>
Date:	Fri, 24 Jun 2016 06:43:04 -0700
From:	Joe Perches <joe@...ches.com>
To:	Borislav Petkov <bp@...en8.de>, LKML <linux-kernel@...r.kernel.org>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Andy Lutomirski <luto@...capital.net>, X86 ML <x86@...nel.org>
Subject: Re: [PATCH 2/3] printk: Make the printk*once() variants return a
 value

On Fri, 2016-06-24 at 10:30 +0200, Borislav Petkov wrote:
> From: Borislav Petkov <bp@...e.de>
> 
> Have printk*once() return a bool which denotes whether the string was
> printed or not so that calling code can react accordingly.

I expected object size to either increase or stay the
same with just this change.

Oddly, at least with gcc 5.3, some defconfig x86-64
objects _decrease_ in size.

for example: drivers/gpu/drm/i915/intel_opregion.o

I presume there's some curiosity in the gcc optimizer
with the evaluation of statement expression macros that
don't return a value.

Perhaps the printk_once macros should end with
	unlikely(__ret_print_once);
like the WARN_ONCE variants.

> Signed-off-by: Borislav Petkov <bp@...e.de>
> Cc: Andrew Morton <akpm@...ux-foundation.org>
> ---
>  include/linux/printk.h | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index f4da695fd615..464fcdddb359 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -108,11 +108,14 @@ struct va_format {
>   * Dummy printk for disabled debugging statements to use whilst maintaining
>   * gcc's format checking.
>   */
> -#define no_printk(fmt, ...)			\
> -do {						\
> -	if (0)					\
> -		printk(fmt, ##__VA_ARGS__);	\
> -} while (0)
> +#define no_printk(fmt, ...)				\
> +({							\
> +	do {						\
> +		if (0)					\
> +			printk(fmt, ##__VA_ARGS__);	\
> +	} while (0);					\
> +	0;						\
> +})
>  
>  #ifdef CONFIG_EARLY_PRINTK
>  extern asmlinkage __printf(1, 2)
> @@ -309,20 +312,24 @@ extern asmlinkage void dump_stack(void) __cold;
>  #define printk_once(fmt, ...)					\
>  ({								\
>  	static bool __print_once __read_mostly;			\
> +	bool __ret_print_once = !__print_once;			\
>  								\
>  	if (!__print_once) {					\
>  		__print_once = true;				\
>  		printk(fmt, ##__VA_ARGS__);			\
>  	}							\
> +	__ret_print_once;					\
>  })
>  #define printk_deferred_once(fmt, ...)				\
>  ({								\
>  	static bool __print_once __read_mostly;			\
> +	bool __ret_print_once = !__print_once;			\
>  								\
>  	if (!__print_once) {					\
>  		__print_once = true;				\
>  		printk_deferred(fmt, ##__VA_ARGS__);		\
>  	}							\
> +	__ret_print_once;					\
>  })
>  #else
>  #define printk_once(fmt, ...)					\

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ