From: Bill Davidsen <davidsen@tmr.com>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Segfault on the i386 enter instruction
Date: Mon, 15 May 2006 16:53:44 -0400 [thread overview]
Message-ID: <4468EA58.8040805@tmr.com> (raw)
In-Reply-To: <Pine.LNX.4.61.0605121003450.9012@chaos.analogic.com>
linux-os (Dick Johnson) wrote:
> On Fri, 12 May 2006, Tomasz Malesinski wrote:
>
>> The code attached below segfaults on the enter instruction. It works
>> when a stack frame is created by the three commented out
>> instructions and also when the first operand of the enter instruction
>> is small (less than about 6500 on my system).
>>
>> AFAIK, the only difference between creating a stack frame with the
>> enter instruction or push/mov/sub is that enter checks if the new
>> value of esp is inside the stack segment limit.
>>
>> I tested it on a vanilla kernel 2.4.26 on Intel Celeron and also on
>> probably non-vanilla 2.6.16.13 running on 3 dual core AMD Opteron,
>> quite busy, server. It is working in 32-bit mode. Interestingly, on
>> the second machine sometimes the program worked correctly.
>>
>> I am not subscribed to the list. Please cc replies to me.
>>
>>
>> .file "a.c"
>> .version "01.01"
>> gcc2_compiled.:
>> .section .rodata
>> .LC0:
>> .string "asdf\n"
>> .text
>> .align 4
>> .globl main
>> .type main,@function
>> main:
>> enter $10008, $0
>> # pushl %ebp
>> # movl %esp,%ebp
>> # subl $10008,%esp
>> addl $-12,%esp
> ^^^^^^^^^^^^^^____________ WTF
> adding a negative number is subtracting that positive value.
Right, adding -12 is the same as subtracting 12. I have no idea what
you're getting at with the next two lines.
> You just subtracted 0xfffffff3 (on a 32-bit machine) from
> the stack pointer. It damn-well better seg-fault!
No, we subtracted 12. I'm not sure where that number came from, it's the
1's complement of 12 but I'm dead sure Linux code isn't running on any
1's comp machines.
--
-bill davidsen (davidsen@tmr.com)
"The secret to procrastination is to put things off until the
last possible moment - but no longer" -me
next prev parent reply other threads:[~2006-05-15 20:54 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
2006-05-15 20:53 ` Bill Davidsen [this message]
-- 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=4468EA58.8040805@tmr.com \
--to=davidsen@tmr.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-os@analogic.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.