Amir Saniyan
Amir Saniyan

Reputation: 13759

How to implement my own system call without recompiling the Linux kernel?

I want to implementing my own system call. (See below link)

http://www.tldp.org/HOWTO/html_single/Implement-Sys-Call-Linux-2.6-i386/

But adding new system call requires kernel compilation.

How to implement my own system call without recompiling the Linux kernel?

Upvotes: 9

Views: 3226

Answers (2)

Ilya Matveychikov
Ilya Matveychikov

Reputation: 4024

Sure, you can.

In short, you'll need to patch the running kernel.

There are at least 2 ways to add a new syscall:

  1. Expand the existing system call tables (sys_call_table and ia32_sys_call_table) and patch system call limit check instruction (usally cmp on x86) at any of the system call entries (system_call, ia32_system_all etc...)
  2. Copy existing system call tables, expand them as needed, patch system call dispatch instruction (usally call on x86) to point to table's copy and patch system call limit check instruction at any of the system call entries.

See this anwers for details:

Implementing Linux System Call using LKM

How do 32-bit applications make system calls on 64-bit Linux?

:)

Upvotes: 4

user149341
user149341

Reputation:

You can't.

Without recompiling the kernel, all you can do is build and load kernel modules, and kernel modules cannot add new system calls.

Upvotes: 15

Related Questions