Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignoring a system call

Tags:

c

linux

x86

gcc

ptrace

I know that you can trap a system call by using ptrace. But what I wanna do is to ignore a system call. So is that possible for ptrace to trap a system call, see its number and if the number is of a system call that has to be ignored, the ptrace stops the system call from proceeding or have the system call return immediately.

The point is that we should have the effect of having the application ignore particular system calls by using ptrace.

like image 216
MetallicPriest Avatar asked Jan 12 '12 19:01

MetallicPriest


People also ask

Can you interrupt a system call?

System calls can be interrupted by any signal, this includes such signals as SIGINT (generated by CTRL-C), SIGHUP, etc.

How system calls are intercepted?

Intercepting a system call means that you want a function of your own to be called instead of the kernel function implementing a given system call everytime the latter in invoked.

What is the importance of system call?

System call provides the services of the operating system to the user programs via Application Program Interface(API). It provides an interface between a process and operating system to allow user-level processes to request services of the operating system.

Can a system call be preempted?

The kernel allows a thread to be preempted by a more favored thread, even when a system call is executing. This capability provides better system responsiveness for large multi-user systems. Because system calls can be preempted, access to global data must be serialized.


1 Answers

You can try PTRACE_GETREGS and PTRACE_SETREGS.
If you change eip to be after the system call, and eax to make the return value valid, the call may be skipped.
But I didn't try it, and wouldn't be surprised if it didn't work.

like image 125
ugoren Avatar answered Sep 21 '22 14:09

ugoren