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: <20080817184510.GA16508@elte.hu>
Date:	Sun, 17 Aug 2008 20:45:10 +0200
From:	Ingo Molnar <mingo@...e.hu>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Rusty Russell <rusty@...tcorp.com.au>,
	Alexey Dobriyan <adobriyan@...il.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Sam Ravnborg <sam@...nborg.org>
Subject: Re: [PATCH] debug: fix BUILD_BUG_ON() for non-constant expressions


* Linus Torvalds <torvalds@...ux-foundation.org> wrote:

> 
> 
> On Sun, 17 Aug 2008, Ingo Molnar wrote:
> > 
> > try the patch below - it only gives this error during build:
> 
> Well, you didn't do it right:
> 
> > +#define __BBO(c)                sizeof(const char[1 - 2*!!(c)])
> > +#define __BBONC(c)              __BBO(!__builtin_constant_p(c))
> > +#define BUILD_BUG_ON_ZERO2(c)    (__BBO(c) - __BBONC(c))
> > +#define BUILD_BUG_ON2(c)         (void)BUILD_BUG_ON_ZERO(c)
> 
> Look at the #define of BUILD_BUG_ON2 a bit more.
> 
> Hint: you're using the _wrong_ BUILD_BUG_ON_ZERO. The old one, not the v2 
> one!

yeah, i already tried various variants earlier today so i really didnt try
that hard with yours. (and i pointed out this mistake in the previous mail)

> That said, with that fixed, there's still something wrong. It does seem 
> like gcc has some very odd interaction there with __builtin_constant_p. 
> Odd.

yeah. I tried various integer arithmetic expressions (which the array trick
relies on) and it didnt work as expected - it's always zero. It only makes
a difference when used in comparisons. (and that's where the kernel uses
__builtin_constant_p quite heavily, and it works fine there.)

Odd indeed.

	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