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: <20200319173101.wufpymi7obhqgoqd@treble>
Date:   Thu, 19 Mar 2020 12:31:01 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Randy Dunlap <rdunlap@...radead.org>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        Linux Next Mailing List <linux-next@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Kees Cook <keescook@...omium.org>
Subject: Re: linux-next: Tree for Mar 18 (objtool)

On Wed, Mar 18, 2020 at 09:05:42PM +0100, Peter Zijlstra wrote:
> "Built-in Function: void __builtin_trap (void)
> 
>     This function causes the program to exit abnormally. GCC implements
>     this function by using a target-dependent mechanism (such as
>     intentionally executing an illegal instruction) or by calling abort.
>     The mechanism used may vary from release to release so you should
>     not rely on any particular implementation."
> 
> Sounds encouraging :-(
> 
> Clearly it now emits UD2, but who knows what it'll do next week.
> 
> I think what happens is that we have code that does:
> 
> 	if (cond)
> 		BUG()/WARN()
> 
> And ubsan figures that @cond is something undefined, and then we get
> transformed into:
> 
> 	if (cond) {
> 		__builtin_trap();
> 		BUG()/WARN()
> 	}
> 
> And presto, double UD2.
>
> Since x86 has GENERIC_BUG unconditionally, we should actually have
> __bug_table entries for each BUG()/WARN() instance, which should allow
> us to distinguish between a proper BUG()/WARN() and this
> __builtin_trap() nonsense.

... except the __builtin_trap() UD2 seems to be coming *after* the BUG
UD2.  Could it be the BUG UD2 itself which is convincing UBSAN to add
the __builtin_trap()?

If the BUG() macro were to use __builtin_trap() instead of the inline
asm UD2, GCC might be able to merge the two UD2's into one, and all
would be well.  But that could be tricky because of the __bug_table
stuff which needs to reference the UD2.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ