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: <20090219185935.GA21820@elte.hu>
Date:	Thu, 19 Feb 2009 19:59:35 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Petr Tesarik <ptesarik@...e.cz>
Cc:	Jeremy Fitzhardinge <jeremy@...p.org>,
	"H. Peter Anvin" <hpa@...or.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] x86: remove unneeded endless loop in BUG()


* Petr Tesarik <ptesarik@...e.cz> wrote:

> Since __builtin_trap() will always generate an illegal 
> instruction, we can replace the explicit asm("ud2") with it.
> 
> This way gcc will understand that the function never returns, 
> plus it won't emit any extra instructions.
> 
> Signed-off-by: Petr Tesarik <ptesarik@...e.cz>

> +#define DO_BUG()						\
> +do {								\
> +	__builtin_trap();					\
> +	printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \
> +	panic("BUG!");						\
> +} while(0)
> +
>  #ifdef CONFIG_DEBUG_BUGVERBOSE
>  
>  #ifdef CONFIG_X86_32
> @@ -14,7 +21,7 @@
>  
>  #define BUG()							\
>  do {								\
> -	asm volatile("1:\tud2\n"				\
> +	asm volatile("1:\n"					\
>  		     ".pushsection __bug_table,\"a\"\n"		\
>  		     __BUG_C0					\
>  		     "\t.word %c1, 0\n"				\
> @@ -22,15 +29,11 @@ do {								\
>  		     ".popsection"				\
>  		     : : "i" (__FILE__), "i" (__LINE__),	\
>  		     "i" (sizeof(struct bug_entry)));		\
> -	for (;;) ;						\
> +	DO_BUG();					\

the problem is that the DO_BUG() will generate the u2d 
instruction into a random place where GCC puts it. It certainly 
wont be in the place where the __bug_table logic above expects 
it.

The result will be cryptic crashes instead of a clean BUG 
message assert.

	Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ