Assembly Syscall Question

From: Ryan Sommers (ryans_at_gamersimpact.com)
Date: 07/31/03

  • Next message: Peter Kieser: "Issues with large drives going back to PIO"
    To: freebsd-hackers@freebsd.org
    Date: Thu, 31 Jul 2003 16:12:27 -0400
    
    

    When making a system call to the kernel why is it necessary to push the
    syscall value onto the stack when you don't call another function?

    Example:

    access.the.bsd.kernel:
     int 80h
     ret

    func:
     mov eax, 4 ; Write
     call access.the.bsd.kernel
    ; End

    Works. However:
    func:
     mov eax, 4 ; Write
     int 80h
    ; End

    Doesn't.

    Now, if you change it to:

    func:
     mov eax, 4 ; Write
     push eax
     int 80h
    ; End

    It does work. I was able to find, "By default, the FreeBSD kernel uses the C
    calling convention. Further, although the kernel is accessed using int 80h,
    it is assumed the program will call a function that issues int 80h, rather
    than issuing int 80h directly," in the developer's handbook. But I can't
    figure out why the second example doesn't work. Is the call instruction
    pushing the value onto the stack in addition to pushing the instruction
    pointer on?

    Thank you in advance.
    PS I'm not on the list.

     

     --
    Ryan "leadZERO" Sommers
    Gamer's Impact President
    ryans@gamersimpact.com
    ICQ: 1019590
    AIM/MSN: leadZERO

     -= http://www.gamersimpact.com =-
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Peter Kieser: "Issues with large drives going back to PIO"

    Relevant Pages

    • Re: push pop ebp
      ... When you push a DWORD on the stack you can access load it into eax like ... mov eax D$esp + 0 will bring the next TOP of the ... So if you push eax|push ebx | push ecx ...
      (alt.lang.asm)
    • [Full-disclosure] PHRACK 64: ATTACKING THE CORE
      ... - The Slab Allocator ... - Slab overflow exploiting: ... - Forcing a kernel path to sleep ... - Stack Frame Flow Recovery ...
      (Full-Disclosure)
    • Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c - bisected
      ... stack usages for you is that they contain a 'cpumask_t' on the stack. ... We can enable MAXSMP and raise the CPU limits some time in the future. ... not accept a specially built kernel, but only a kernel that has been ... know how extensively these distributions test and certify for many known ...
      (Linux-Kernel)
    • Re: Interrupt context...
      ... > gone through most of the posts on interrupt in usenet. ... > kernel stack and ISR is executed. ... More may be saved depending on the architecture. ... Here the kernel have assembler code to save all general ...
      (comp.os.linux.development.system)
    • Re: The Linux Staging tree, what it is and is not.
      ... if you compromize them and write the wrong ones to the stack, ... Load two user space fieldbus stacks on the same network card (remembering ... right, but that's the same, no matter if it runs in kernel or user ... need an objdict API to userspace...? ...
      (Linux-Kernel)