Re: kernel stack challenge

From: Muli Ben-Yehuda (mulix_at_mulix.org)
Date: 04/04/04

  • Next message: Ben Mansell: "Re: Is POLLHUP an input-only or bidirectional condition? (was: epoll reporting events when it hasn't been asked to)"
    Date:	Sun, 4 Apr 2004 20:38:25 +0200
    To: Sergiy Lozovsky <serge_lozovsky@yahoo.com>
    
    
    

    On Sun, Apr 04, 2004 at 11:24:38AM -0700, Sergiy Lozovsky wrote:

    > I wonder how it is possible to access task struct
    > having current stack pointer. %esp points at the
    > middle of the stack (when we are in the kernel) when
    > interrupt occures.

    Look at the curren()t and get_current() macros. Basically, the stack
    is page aligned, so with the proper masking of %esp you can get to the
    bottom of the stack.

    See http://www.kernelnewbies.org/faq/, "how does get_current work?".

    Cheers,
    Muli

    -- 
    Muli Ben-Yehuda
    http://www.mulix.org | http://mulix.livejournal.com/
    
    

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/



  • Next message: Ben Mansell: "Re: Is POLLHUP an input-only or bidirectional condition? (was: epoll reporting events when it hasn't been asked to)"

    Relevant Pages

    • Re: Conditional breakpoint based on caller / module
      ... When a function call is made, the caller function copies the following information ... ESP register is a pointer, which in normal circumstances always points ... to some area of the stack. ... When you set the breakpoint at the beginning ...
      (microsoft.public.vc.debugger)
    • Re: Stack frames
      ... > ESP with the common stack frame models. ... ESP, why not simply move the "MOV esp, ebp" ... You can't rely on "size(locals + align)" to keep the ...
      (alt.lang.asm)
    • Re: further optimizations
      ... mov al B$edx;ok ... The users stack is not affected with this, ... but everything below ESP is never usable anyway... ... It had reprogrammed what you call IDT (interrupt table?) and after ...
      (alt.lang.asm)
    • Re: Newbie question...
      ... and esp, -16 ... mov ebp, esp ... Since the x86 increments esp with "pop", the new stack pointer is aligned ... add eax, 15 ...
      (alt.lang.asm)
    • Re: [x86] Access off the bottom of stack causes a segfault?
      ... > My compiler is generating accesses off the bottom of the stack (address ... > below %esp). ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)