9

I'm reading Linux Kernel Development by Robert Love and one of the exercises he does is to create a system call (page 106). The problem is that I am unable to find the system call table file in v3.9 for the x86_32 architecture. I know that he's using the version 2.6.xx but I don't know if that version will work with the distribution that I'm using as it is pretty old so I would rather prefer v3.9.

More information: The exercise of which I am speaking is the following: Add an entry to the end of the system call table.This needs to be done for each architecture that supports the system call (which, for most calls, is all the architectures).The position of the syscall in the table, starting at zero, is its system call number. For example, the tenth entry in the list is assigned syscall number nine.

Solved using the following approach: The system call table is located in arch/x86/syscalls/syscall_32.tbl for the x86 architecture. Thanks to Sudip Mukherjee for his help.

Another approach is the following: http://lists.kernelnewbies.org/pipermail/kernelnewbies/2013-July/008598.html Thanks to Srinivas Ganji for his help too.

5
  • where did you search for it? Commented Jul 15, 2013 at 11:05
  • In the book it says that it is located in entry.S but as far as I know this has been changed in the last versions. So I've searched in arch/x86/kernel where I've found the entry_32.S file but I haven't found the table there neither Commented Jul 15, 2013 at 11:28
  • It would appear to be here Commented Jul 15, 2013 at 11:51
  • It seems that in kernel v3.0 the table was in a file called syscall_table_32.S but I don't find it in v3.9. Source: emntech.com/docs/syscall_emntech.pdf Commented Jul 15, 2013 at 19:28
  • see also Where do you find the syscall table for Linux? Commented Nov 7, 2024 at 0:08

4 Answers 4

12

From linux kernel 4.2, the system call table has been moved from arch/x86/syscalls/syscall_64.tbl to arch/x86/entry/syscalls/syscall_64.tbl

Here is the corresponding commit:

commit 1f57d5d85ba7f1f467173ff33f51d01a91f9aaf1 Author: Ingo Molnar <[email protected]> Date: Wed Jun 3 18:36:41 2015 +0200 x86/asm/entry: Move the arch/x86/syscalls/ definitions to arch/x86/entry/syscalls/ The build time generated syscall definitions are entry code related, move them into the arch/x86/entry/ directory. 
Sign up to request clarification or add additional context in comments.

Comments

8

Create a testing folder in src root: src/linux-3.4/testing/, then put inside this folder:
- a file that contains syscall code: strcpy.c

#include <linux/linkage.h> #include <linux/kernel.h> asmlinkage long sys_strcpy(char *dest, char *src) { int i=0; while(src[i]!='\0') { dest[i]=src[i++]; } dest[i]='\0'; printk(" Done it "); return 0; } 

and the Makefile that contains just the following line:

obj-y:=strcpy.o 

Add an entry to the syscall table and the prototype of the function:
- edit the file src/linux-3.4/arch/x86/syscalls/syscall_32.tbl by adding this line to the entry 223 that is free

 223 i386 strcpy sys_strcpy 

Edit the file src/linux-3.4/include/linux/syscalls.h by adding the prototype of the function

asmlinkage long sys_strcpy(char *dest, char *src); 

Edit the main Makefile in the src root (src/linux-3.4/Makefile) by adding the testing folder created before, as follow:

core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ testing/ 

Comments

4

For systems where audit is enabled, a table of the syscalls may be easily retrieved with:

ausyscall --dump 

For example:

$ ausyscall --dump Using x86_64 syscall table: 0 read 1 write 2 open 3 close 4 stat 5 fstat 6 lstat 7 poll 8 lseek 9 mmap 10 mprotect ...SNIP... 

Comments

0

A similar question on SO where the OP seems to have solved it:

New syscall not found (linux kernel 3.0.0) where should I start looking?

The file seems to be arch/x86/kernel/syscall_table_32.c.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.