All of lore.kernel.org
 help / color / mirror / Atom feed
* no crash after setting ESP to 0 in module
@ 2003-06-23  0:37 Julien Oster
  2003-06-23 12:58 ` Mikulas Patocka
  0 siblings, 1 reply; 3+ messages in thread
From: Julien Oster @ 2003-06-23  0:37 UTC (permalink / raw)
  To: linux-kernel


Hello,

I already asked this once, but since I got no answer I figured I'll
try it again, maybe this time someone has the time to quickly explain
me that thing.

If I build a kernel module which does something like, say:

MOV ESP, 0

in init_module() then I get an oops, insmod (or whatever process tried
to insert the module) gets killed by the kernel and everything goes on
like that never happened.

My question is now: why? How? I really expect the processor to fail
into a triple fault when doing such a nasty thing, since I am in Ring
0 and there isn't any stack to handle the stack fault exception.

Where's the magic?

Regards,
Julien


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: no crash after setting ESP to 0 in module
  2003-06-23  0:37 no crash after setting ESP to 0 in module Julien Oster
@ 2003-06-23 12:58 ` Mikulas Patocka
  0 siblings, 0 replies; 3+ messages in thread
From: Mikulas Patocka @ 2003-06-23 12:58 UTC (permalink / raw)
  To: Julien Oster; +Cc: linux-kernel

> Hello,
>
> I already asked this once, but since I got no answer I figured I'll
> try it again, maybe this time someone has the time to quickly explain
> me that thing.
>
> If I build a kernel module which does something like, say:
>
> MOV ESP, 0
>
> in init_module() then I get an oops, insmod (or whatever process tried
> to insert the module) gets killed by the kernel and everything goes on
> like that never happened.
>
> My question is now: why? How? I really expect the processor to fail
> into a triple fault when doing such a nasty thing, since I am in Ring
> 0 and there isn't any stack to handle the stack fault exception.
>
> Where's the magic?

Processor will do double fault prior to triple fault. Double fault
exception 8 points to a task switch gate --- and task switch doesn't
require correct ESP. So it loads new ESP from task state segment of that
gate and calls doublefault_fn.

See file arch/i386/kernel/doublefault.c

Mikulas


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: no crash after setting ESP to 0 in module
       [not found] ` <1zf8.2M8.5@gated-at.bofh.it>
@ 2003-06-25  8:57   ` Julien Oster
  0 siblings, 0 replies; 3+ messages in thread
From: Julien Oster @ 2003-06-25  8:57 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: linux-kernel

Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> writes:

Hello Mikulas,

>> Where's the magic?

> Processor will do double fault prior to triple fault. Double fault
> exception 8 points to a task switch gate --- and task switch doesn't
> require correct ESP. So it loads new ESP from task state segment of that
> gate and calls doublefault_fn.

A task switch gate! Finally that makes sense to me. Thanks for
pointing this out!

Regards,
Julien

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-06-25  8:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-23  0:37 no crash after setting ESP to 0 in module Julien Oster
2003-06-23 12:58 ` Mikulas Patocka
     [not found] <1nxp.Y9.15@gated-at.bofh.it>
     [not found] ` <1zf8.2M8.5@gated-at.bofh.it>
2003-06-25  8:57   ` Julien Oster

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.