0

I was following this guide to add my own custom system call inside the Linux kernel "Adding a Hello World System Call to Linux Kernel".

In Step 5, it asks to modify the system call table by going into

/usr/src/linux-headers-x.x.x-xx/arch/x86/entry/syscalls/

I looked into my system with OS version- Ubuntu 20.04.1 and then kernel version 5.4.0-42, but the specific directory had only three files

Makefile syscallhdr.sh syscalltbl.sh

I searched online and found that the newer versions of Linux use this bash script syscalltbl.sh to generate the desired file containing all system call numbers. So thought of running this file, but couldn't due to permission issues(I am newbie in Linux, so didn't found it a good idea to touch things much).

Then I searched for another guide, since the the guide I mentioned above was about 2 years old, and so found this video tutorial created just 4 months back, "Add your own system call to Linux Kernel".

In this the guy uses the already present syscall_64.tbl file (the .sh file is too present), so I thought this might be some problem with my machine only as the "Official GitHub Repository" also contains the .tbl file along with bash script.

I upgraded my kernel to the latest version 5.9.0-050900-generic, but still the directory

/usr/src/linux-headers-5.9.0-050900/arch/x86/entry/syscalls

has only the bash files with the Makefile.

So where exactly can I find the syscall_64.tbl in my system?

The only thing which comes to my mind is creating syscall_64.tbl myself in the the mentioned directory using the syscall_64.tbl file available on the GitHub. But I believe this is a not good idea, there might be risks associated with it, which I have no clue.

  • I have tried looking for syscall_64.tbl, using "whereis syscall_64.tbl" command, but it just prints "syscall_64:", nothing else. – deadLock Oct 23 at 14:39
0

This file is in the source code for the Linux kernel. You can grab a tarball for the latest release from kernel.org.

If you want to play around with modifying the Linux kernel, I would do so by building a new kernel (separate from your main system) and running it in a virtual machine like QEMU. You can find various guides on the internet like "Build and run minimal Linux / Busybox systems in Qemu" that show you how to get a little development environment up and running.

| improve this answer | |
  • I guess you have answered just based on the question title and not the text provided. I already did upgrade to the latest kernel, but I am not able to find the file in the folder, where it usually lies. – deadLock Oct 23 at 16:26
  • That's because when you install a kernel package on a binary distro like Debian or Fedora, you don't get the sources. Just the binaries (that go in /boot), and maybe the headers if you've installed some external modules. – Matthew Smith Oct 23 at 16:51
  • So I should upgrade my kernel again using the link you have provided? But, I am not sure how to proceed, could you mention the terminal commands I should use for the purpose? Also, it would be nice if you add your reply in the answer itself. – deadLock Oct 24 at 2:39
  • @deadLock I reject your edit, please, make an answer of your own. – Archemar Oct 26 at 10:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.