System Call Invocation

System calls are issued by calling the PAL_callsys PALcode instruction. PALcode stands for Privileged Architecture Library (PAL) instructions, which are divided into two groups ” unprivileged PALcodes , which can be called in user mode and kernel mode, and privileged PALcodes , which can be called only from kernel mode. To use the symbolic names of the PALcodes , you will need to include the /usr/include/alpha/pal.h <alpha/pal.h> header file in your assembly code. PAL_callsys is in the unprivileged PALcode group . User-mode programs execute it in order to transfer control to kernel mode, thus being dispatched to the requested system call handler. The requested system call is passed as an index to the initial trap handler, which is used to gather the actual system call handler. The index to the system call, also known as the system call number , is passed to the kernel mode with the v0 register. Arguments to system calls are passed with the a0-a5 registers similar to the user-mode function calls. The following code is a sample system call invocation routine from user mode for the setuid system call.

 #include <alpha/regdef.h> #include <alpha/pal.h>      .text      .arch     generic      .align 4      .globl  main      .ent      main main:      bis  zero, zero, a0       #argument to setuid(), uid=0      addq zero, 0x17, v0       #setuid system call number.      PAL_callsys               #trap to kernel mode. 


The Shellcoder's Handbook. Discovering and Exploiting Security
Hacking Ubuntu: Serious Hacks Mods and Customizations (ExtremeTech)
ISBN: N/A
EAN: 2147483647
Year: 2003
Pages: 198
Authors: Neal Krawetz

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net