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:	Tue, 02 Oct 2012 09:57:47 -0500
From:	Daniel Santos <danielfsantos@....net>
To:	Michel Lespinasse <walken@...gle.com>
CC:	Daniel Santos <daniel.santos@...ox.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Andi Kleen <ak@...ux.intel.com>,
	Andrea Arcangeli <aarcange@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Christopher Li <sparse@...isli.org>,
	David Daney <david.daney@...ium.com>,
	David Howells <dhowells@...hat.com>,
	Joe Perches <joe@...ches.com>,
	Konstantin Khlebnikov <khlebnikov@...nvz.org>,
	linux-sparse@...r.kernel.org,
	Paul Gortmaker <paul.gortmaker@...driver.com>,
	Pavel Pisa <pisa@....felk.cvut.cz>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH 8/10] bug.h: Make BUILD_BUG_ON generate compile-time error

On 10/01/2012 07:48 PM, Michel Lespinasse wrote:
> On Fri, Sep 28, 2012 at 4:20 PM, Daniel Santos <daniel.santos@...ox.com> wrote:
>> Negative sized arrays wont create a compile-time error in some cases
>> starting with gcc 4.4 (e.g., inlined functions), but gcc 4.3 introduced
>> the error function attribute that will.  This patch modifies
>> BUILD_BUG_ON to behave like BUILD_BUG already does, using the error
>> function attribute so that you don't have to build the entire kernel to
>> discover that you have a problem, and then enjoy trying to track it down
>> from a link-time error.
> Few other alternatives I've seen used in other projects (from memory,
> so I may have gotten the details wrong):
>
> 1) if (condition) { __asm__(".error \"Some error message\""); }
> 2) switch (0) {
>     case 0: break;
>     case !condition: break;
>     }
>     (fails to compile if !condition evaluates to 0)
>
> If you can get the first suggestion to work it'd be nice, as you could
> get some descriptive error message (you can add the line number there
> too).
Thanks for this info.  I'm still pretty noob-ish in modern assembly, but
is the .error directive available on all supported assemblers?  It
appears to have been added to GNU binutils in version 2.16 from what I
can tell (http://sourceware.org/binutils/docs-2.16/as/Error.html).  If
it is supported, I would definitely prefer that one as a fallback option.

I did a search on sources for the regex \.error\s+\\?" and didn't turn
up anything outside of arch/, so I'm guessing this may not be completely
portable.  Note also that these BUILD_BUG* macros do emit an error
message on gcc 4.3+ using __attribute__((error("msg"))).

Daniel
--
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