public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Denis Vlasenko <vda@ilport.com.ua>
To: "linux-os \(Dick Johnson\)" <linux-os@analogic.com>
Cc: "Tomasz Malesinski" <tmal@mimuw.edu.pl>, linux-kernel@vger.kernel.org
Subject: Re: Segfault on the i386 enter instruction
Date: Fri, 12 May 2006 17:53:00 +0300	[thread overview]
Message-ID: <200605121753.00978.vda@ilport.com.ua> (raw)
In-Reply-To: <Pine.LNX.4.61.0605121033030.9091@chaos.analogic.com>

On Friday 12 May 2006 17:42, linux-os (Dick Johnson) wrote:
> >>> 	enter $10008, $0
> >>> #	pushl %ebp
> >>> #	movl %esp,%ebp
> >>> #	subl $10008,%esp
> >>> 	addl $-12,%esp
> >>          ^^^^^^^^^^^^^^____________ WTF
> >>          adding a negative number is subtracting that positive value.
> >>          You just subtracted 0xfffffff3 (on a 32-bit machine) from
> >>          the stack pointer. It damn-well better seg-fault!
> >
> > No. Try it yourself.
> > --
> > vda
> 
> It doesn't matter. It means that you still own the space there
> (it's mapped into your process). The code is bogus, broken beyond
> all repair. It has nothing to do with 'enter' it has to do with
> putting the stack pointer (wrapping it) to somewhere it shouldn't
> be. The stack pointer is normally around 0xafff0000. It just got
> wrapped down past zero up to fafff00d, then stuff got pushed
> onto it for the call.

Obviously you

(a) Don't want to actually try to compile and run it.
It will run. For Tomasz, it runs ok with 3-insn instruction sequence
instead of enter. For me, it works just fine with enter. But it works.
Why do you think it is not enough?

(b) can't do 32-bit math. You made two mistakes.
    -12 is 0xfffffff4, not 0xfffffff3.
    0xafff0000 + 0xfffffff4 = 0xaffefff4, not 0xfafff00d

and
(c) do not realize that 32bit i386+ CPUs check segment limits
    AFTER performing 32bit math (i.e. overflow into 33th bit
    is truncated instead of triggering limit violation)
--
vda

  reply	other threads:[~2006-05-12 14:53 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-12 13:16 Segfault on the i386 enter instruction Tomasz Malesinski
2006-05-12 13:47 ` Denis Vlasenko
2006-05-12 13:50 ` Andi Kleen
2006-05-12 14:03   ` Denis Vlasenko
2006-05-12 15:31   ` Tomasz Malesinski
2006-05-15 11:36     ` Bart Hartgers
2006-05-15 11:46       ` Andi Kleen
2006-05-15 13:36       ` linux-os (Dick Johnson)
2006-05-15 14:19         ` Bart Hartgers
2006-05-12 14:07 ` linux-os (Dick Johnson)
2006-05-12 14:20   ` Denis Vlasenko
2006-05-12 14:42     ` linux-os (Dick Johnson)
2006-05-12 14:53       ` Denis Vlasenko [this message]
2006-05-15 20:53   ` Bill Davidsen
  -- strict thread matches above, loose matches on Subject: below --
2006-05-14 17:56 Stas Sergeev
2006-05-15  7:40 ` Andi Kleen
2006-05-15 17:15   ` Stas Sergeev
2006-05-15 18:44     ` Andi Kleen
2006-05-15 19:38       ` Stas Sergeev
2006-05-15 19:56         ` Lee Revell
2006-05-15 22:49           ` Ingo Oeser
2006-05-15 22:56             ` Lee Revell
2006-05-16  2:29 Chuck Ebbert
2006-05-16  9:32 ` Andi Kleen
2006-05-17  8:20 Chuck Ebbert

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=200605121753.00978.vda@ilport.com.ua \
    --to=vda@ilport.com.ua \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    --cc=tmal@mimuw.edu.pl \
    /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