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: <20140619152228.GA16426@thin>
Date:	Thu, 19 Jun 2014 08:22:28 -0700
From:	Josh Triplett <josh@...htriplett.org>
To:	Bart Van Assche <bvanassche@....org>
Cc:	Arnd Bergmann <arnd@...db.de>,
	Andrew Morton <akpm@...ux-foundation.org>,
	linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] bug: Fix CONFIG_BUG=n BUG_ON()

On Thu, Jun 19, 2014 at 03:28:19PM +0200, Bart Van Assche wrote:
> Patch "bug: Make BUG() always stop the machine" changed the
> behavior of BUG() with CONFIG_BUG=n from a no-op into an infinite
> loop. Modify the definition of BUG_ON() accordingly such that the
> behavior of BUG_ON(1) is identical to that of BUG().

No, this patch should not go in.  CONFIG_BUG=n exists for this exact
purpose; if you want BUG_ON to do something then use CONFIG_BUG=y with
BUGVERBOSE disabled instead.

Making BUG() stop the machine even with CONFIG_BUG=n eliminated a number
of compiler warnings about code that should be unreachable, and added
fairly little size to the kernel.  BUG_ON, on the other hand, occurs in
far more places, adds much more size if enabled, and tends to serve as
an assert of a condition; it makes perfect sense to allow compiling out
an assert, and compiling it out does not introduce any compiler
warnings.

What problem are you trying to solve here?  With this change,
CONFIG_BUG=n and CONFIG_BUG=y would become effectively equivalent.

Also:

> --- a/include/asm-generic/bug.h
> +++ b/include/asm-generic/bug.h
> @@ -142,7 +142,7 @@ extern void warn_slowpath_null(const char *file, const int line);
>  #endif
>  
>  #ifndef HAVE_ARCH_BUG_ON
> -#define BUG_ON(condition) do { if (condition) ; } while (0)
> +#define BUG_ON(condition) do { } while (unlikely(condition))

Even if making this change, it should not take this form, which would
evaluate the conditional repeatedly.  See the form used with
CONFIG_BUG=y (without HAVE_ARCH_BUG_ON), defined earlier in the same
file.

- Josh Triplett
--
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