Linux-Next discussions
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Randy Dunlap <rdunlap@infradead.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Kees Cook <keescook@chromium.org>
Subject: Re: linux-next: Tree for Mar 18 (objtool)
Date: Thu, 19 Mar 2020 12:31:01 -0500	[thread overview]
Message-ID: <20200319173101.wufpymi7obhqgoqd@treble> (raw)
In-Reply-To: <20200318200542.GK20730@hirez.programming.kicks-ass.net>

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


  parent reply	other threads:[~2020-03-19 17:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-18 11:09 linux-next: Tree for Mar 18 Stephen Rothwell
2020-03-18 16:14 ` linux-next: Tree for Mar 18 (drivers/base/power/sysfs.c) Randy Dunlap
2020-03-19  3:20   ` Stephen Rothwell
2020-03-19 14:47     ` [PATCH net-next] sysfs: fix static inline declaration of sysfs_groups_change_owner() Christian Brauner
2020-03-19 16:19       ` Randy Dunlap
2020-03-20  4:17       ` David Miller
2020-03-18 16:48 ` linux-next: Tree for Mar 18 (objtool) Randy Dunlap
2020-03-18 16:55   ` Josh Poimboeuf
2020-03-18 18:23   ` Josh Poimboeuf
2020-03-18 20:05     ` Peter Zijlstra
2020-03-19 11:12       ` Peter Zijlstra
2020-03-19 17:31       ` Josh Poimboeuf [this message]
2020-03-19 17:33         ` Josh Poimboeuf
2020-03-19 17:40           ` Josh Poimboeuf
2020-03-19 17:45             ` Josh Poimboeuf
2020-03-20  8:26               ` Peter Zijlstra
2020-03-20 18:35                 ` Kees Cook
2020-03-24 16:44                   ` Josh Poimboeuf
2020-03-24 18:18                     ` Kees Cook
2020-03-24 22:24                       ` Josh Poimboeuf
2020-03-26  5:57                         ` Kees Cook
2020-03-26 16:31                           ` Josh Poimboeuf
2020-03-26 18:36                             ` Kees Cook
2020-03-27  3:55                               ` Josh Poimboeuf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200319173101.wufpymi7obhqgoqd@treble \
    --to=jpoimboe@redhat.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox