linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Joe.Buck@synopsys.COM (Joe Buck)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: Convert BUG() to use unreachable()
Date: Thu, 17 Dec 2009 10:35:17 -0800	[thread overview]
Message-ID: <20091217183517.GC10707@synopsys.com> (raw)
In-Reply-To: <20091217181718.GA4440@n2100.arm.linux.org.uk>

On Thu, Dec 17, 2009 at 10:17:18AM -0800, Russell King - ARM Linux wrote:
> > It shouldn't as *(int *)0 = 0; might trap.  But if you want to be sure
> > use
> >    __builtin_trap ();
> > instead for the whole sequence (the unreachable is implied then).
> > GCC choses a size-optimal trap representation for your target then.
> 
> How is "size-optimal trap" defined?  The point of "*(int *)0 = 0;" is
> to cause a NULL pointer dereference which is trapped by the kernel to
> produce a full post mortem and backtrace which is easily recognised
> as a result of this code.

With something like __builtin_trap, the compiler knows that your intent
is to cause a trap.  But it's asking for trouble, and for future
flame wars between kernel developers and gcc developers, to put in
sequences that happen to do the right thing if the compiler does
no optimizations whatsoever, but that might be messed up by optimizations
because they are code sequences whose behavior is undefined.

Besides, didn't I see a whole bunch of kernel security patches related
to null pointer dereferences lately?  If page 0 can be mapped, you
suddenly won't get your trap.

  reply	other threads:[~2009-12-17 18:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08  9:55 [PATCH] ARM: Convert BUG() to use unreachable() Uwe Kleine-König
2009-12-10 17:50 ` Russell King - ARM Linux
     [not found]   ` <4B213627.5000007@caviumnetworks.com>
2009-12-16 13:58     ` Uwe Kleine-König
2009-12-17 15:01 ` Jamie Lokier
     [not found]   ` <4B2A65C6.7080009@caviumnetworks.com>
2009-12-17 17:17     ` Richard Guenther
2009-12-17 18:17       ` Russell King - ARM Linux
2009-12-17 18:35         ` Joe Buck [this message]
2009-12-17 19:06           ` Russell King - ARM Linux
2009-12-17 19:14             ` Joe Buck
2009-12-17 19:33               ` Russell King - ARM Linux
2009-12-17 19:38               ` Jamie Lokier
2009-12-17 19:48                 ` Russell King - ARM Linux
2009-12-17 19:58                   ` Russell King - ARM Linux
2009-12-17 19:04         ` Jamie Lokier
2009-12-21 19:30         ` Richard Henderson
2009-12-21 20:10           ` Russell King - ARM Linux
2009-12-22 14:09             ` Dave Korn
2009-12-22 14:12               ` Russell King - ARM Linux
2009-12-22 14:49                 ` Dave Korn
2009-12-22 11:33       ` Paolo Bonzini

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=20091217183517.GC10707@synopsys.com \
    --to=joe.buck@synopsys.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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;
as well as URLs for NNTP newsgroup(s).