Skip to content

Commit 2ede8f2

Browse files
committed
doc: Add documentation for updating syscalls.csv
Add documentation on how to update syscalls.csv. Here are the exact steps and results for updating syscalls.csv to kernels v6.14 through v7.0-rc7 $ apt install libc6-dev-x32 $ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git $ git clone https://github.com/hrw/syscalls-table.git $ git clone git@github.com:<yourrepo>/libseccomp.git $ cd libseccomp $ vim include/seccomp-kvers.h --> add new syscall enumerations $ time ./src/arch-build-kver-tables.py -d ../syscalls-table -k ../linux -V 6.14,6.15,6.16,6.17,6.18,6.19,7.0-rc7 Building version table for kernel 6.14 Building version table for kernel 6.15 Building version table for kernel 6.16 Building version table for kernel 6.17 Building version table for kernel 6.18 Building version table for kernel 6.19 Building version table for kernel 7.0-rc7 real 2m47.672s user 1m22.094s sys 1m23.954s $ time ./src/arch-update-syscalls-csv.py -a -d ./ -k ../linux -c src/syscalls.csv -V 6.14,6.15,6.16,6.17,6.18,6.19,7.0-rc7 Updating src/syscalls.csv version table for kernel 6.14 Updating src/syscalls.csv version table for kernel 6.15 Updating src/syscalls.csv version table for kernel 6.16 Updating src/syscalls.csv version table for kernel 6.17 Updating src/syscalls.csv version table for kernel 6.18 Updating src/syscalls.csv version table for kernel 6.19 Updating src/syscalls.csv version table for kernel 7.0-rc7 real 0m30.112s user 0m20.716s sys 0m9.547s $ vim include-seccomp-syscalls.h --> add new syscall __SNR and __PNR entries as appropriate $ ./src/arch-syscall-check --> Make changes as recommended by this script --> Re-run this script until there are no more changes to be made $ cd src $ ./arch-syscall-validate -c syscalls-prev.csv ../../linux/ $ git diff HEAD syscalls.csv $ diff syscalls-prev.csv with syscalls.csv Signed-off-by: Tom Hromatka (Oracle) <tom.hromatka@gmail.com>
1 parent c4a85cc commit 2ede8f2

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,105 @@ base, and can be enabled via the "--enable-code-coverage" configure flag and
6464
the "check-code-coverage" make target. Additional details on generating code
6565
coverage information can be found in the .travis.yml file.
6666

67+
## How to Update the syscalls.csv Table
68+
69+
*** NOTE - This currently can only be done on Ubuntu ***
70+
71+
1. Install dependencies
72+
73+
In addition to the normal libseccomp package dependencies, the following
74+
packages must also be installed:
75+
```
76+
apt install libc6-dev-x32
77+
```
78+
79+
1. Download source packages
80+
81+
Download the following source packages:
82+
```
83+
git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
84+
git clone https://github.com/hrw/syscalls-table.git
85+
git clone git@github.com:<yourrepo>/libseccomp.git
86+
```
87+
88+
1. Add new kernel version enumerations
89+
90+
The first line of [src/syscalls.csv](https://github.com/seccomp/libseccomp/blob/main/src/syscalls.csv)
91+
contains the newest kernel version known by libseccomp. Add new kernel
92+
version enumerations to the end of the `enum scmp_kver` enumeration in
93+
[seccomp-kvers.h](https://github.com/seccomp/libseccomp/blob/main/include/seccomp-kvers.h).
94+
95+
Optional - Add new kernel versions to the `kernel_versions` list in
96+
[arch-build-kver-tables.py](https://github.com/seccomp/libseccomp/blob/main/src/arch-build-kver-tables.py).
97+
98+
1. Build the table(s) of architectures, syscalls, and syscall numbers
99+
100+
Using the [syscalls-table](https://github.com/hrw/syscalls-table) tool,
101+
build the tables of architectures, syscalls, and syscall numbers for the
102+
new kernel versions.
103+
104+
```
105+
cd libseccomp
106+
./src/arch-build-kver-tables.py -d ../syscalls-table -k ../linux -V [Kernel Version(s)]
107+
108+
# example:
109+
./src/arch-build-kver-tables.py -d ../syscalls-table -k ../linux -V 6.14,6.15,6.16,6.17,6.18,6.19,7.0-rc7
110+
```
111+
112+
1. Add the tables to syscalls.csv
113+
114+
Parse the tables generated in the previous step and add the data to
115+
syscalls.csv.
116+
117+
```
118+
./src/arch-update-syscalls-csv.py -a -d ./ -k ../linux -c src/syscalls.csv -V [Kernel Version(s)]
119+
120+
# example
121+
./src/arch-update-syscalls-csv.py -a -d ./ -k ../linux -c src/syscalls.csv -V 6.14,6.15,6.16,6.17,6.18,6.19,7.0-rc7
122+
```
123+
124+
1. Update seccomp-syscalls.h with new syscalls
125+
126+
Run `cd src && ./arch-syscall-check` to determine if any new syscalls were
127+
added and if they require __PNR and/or __SNR definitions. If this tool
128+
identifies missing definitions, add them to
129+
[include/seccomp-syscalls.h](https://github.com/seccomp/libseccomp/blob/main/include/seccomp-syscalls.h). [Here](https://github.com/seccomp/libseccomp/commit/f01e67509e45c672f4bdd643d94d90867cc19d90)
130+
is an example of the syscalls that were added to kernel version v6.12.
131+
132+
133+
1. Build the legacy syscalls.csv table (optional but recommended)
134+
135+
Prior to tracking the kernel version where syscalls were added, libseccomp
136+
employed internal tools to build the syscalls.csv table. These tools can
137+
be used to validate the syscall numbers and their architectures. Note that
138+
they cannot be used to validate the kernel version number.
139+
140+
```
141+
./autogen.sh && ./configure --enable-python && make check-build
142+
143+
cd src
144+
make arch-syscall-dump
145+
./arch-syscall-validate -c syscalls-prev.csv ../../linux/
146+
```
147+
148+
1. Compare CSVs
149+
150+
Compare the checked-in (HEAD) CSV with the newly-generated syscalls.csv.
151+
Verify the following:
152+
* All new syscall names were properly added
153+
* If a syscall number changed, it should only have transitioned from `PNR`
154+
to a valid number. If a number changed for an architecture, verify that
155+
its associated kernel version is correct
156+
* No syscall rows were deleted
157+
158+
If you built `syscalls-prev.csv` in the previous step, do the same comparisons
159+
as outlined above. Again, note that `syscalls-prev.csv` does not contain
160+
kernel version information, so only the syscall names, syscall numbers, and
161+
architectures can be verified.
162+
163+
There are many tools to compare CSVs. This [tool](https://www.textcompare.org/csv/)
164+
has been especially useful.
165+
67166
## Explain Your Work
68167

69168
At the top of every patch you should include a description of the problem you

0 commit comments

Comments
 (0)