What's the best way to enumerate all available Linux syscalls?
To clarify, I'm asking how to discover which syscalls are being filtered by seccomp while running in a containerized environment.
What's the best way to enumerate all available Linux syscalls?
To clarify, I'm asking how to discover which syscalls are being filtered by seccomp while running in a containerized environment.
I have found two possible methods to enumerate Linux syscalls. One involves a bash one-liner, but is dependent on your distro shipping all of the relevant manpages. The other, strace, a tool that can be used to discover and track any and all possible syscalls.
strace can be found on GitHub and GitLab. I cannot vouch for your environment, and if you wish to check for syscalls inside a container this solution would not be ideal, however it works better than the bash one-liner as manpages may not be installed.
Filter by type of syscall:
strace -e trace=%desc Trace all file descriptor related system calls. %file Trace all system calls which take a file name as an argument. %fstat Trace fstat and fstatat syscall variants. %fstatfs Trace fstatfs, fstatfs64, fstatvfs, osf_fstatfs, and osf_fstatfs64 system calls. %ipc Trace all IPC related system calls. %lstat Trace lstat syscall variants. %memory Trace all memory mapping related system calls. %network Trace all the network related system calls. %process Trace all system calls which involve process management. %pure Trace syscalls that always succeed and have no arguments. %signal Trace all signal related system calls. %stat Trace stat syscall variants. %statfs Trace statfs, statfs64, statvfs, osf_statfs, and osf_statfs64 system calls. %%stat Trace syscalls used for requesting file status. %%statfs Trace syscalls related to file system statistics.
However you if you have a list of specific syscalls you wish to look for you can use the following command:
strace -e [syscall1],[syscall2],[syscall3],...,[syscalln]
I am also including this blog for more information on strace.
I will be referencing the syscalls manpage, Link 1 Link 2, as well as this webpage with advice on how to complete the task of enumerating all available syscalls for a given Linux system.
The individual on the webpage suggest you can reference your manpages for a full list of syscalls. This example gives output in an annotated list.
ls /usr/share/man/man2 | sed -e s/.2.gz//g | xargs man -s 2 -k | sort | grep -v 'unimplemented system calls'
Again, I would note that if your distribution fails to ship all of your packages with all of their relevant manpages then the bash one-liner would fall short. If the annotated list output is not needed and this solution does not fit with your desired output, please update your post to better define what your goal is.
I will also include a link to a python tool used to look up syscalls. This could potentially be a good reference to compare what syscalls you discover with what is available.
Please comment if you have any questions or issues with this answer. I highly suggest you read through each link I have provided thoroughly before attempting the commands. I appreciate feedback to correct any misconceptions and to improve my posts. I can update my answer as needed.
Best of Luck!