Skip to content

Commit

Permalink
PVF worker: Maintain lists of used syscalls (#1663)
Browse files Browse the repository at this point in the history
Co-authored-by: Mira Ressel <[email protected]>
  • Loading branch information
mrcnski and Mira Ressel authored Oct 17, 2023
1 parent b14018f commit a1171e6
Show file tree
Hide file tree
Showing 7 changed files with 803 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,8 @@ rustflags = [
"-Aclippy::extra-unused-type-parameters", # stylistic
"-Aclippy::default_constructed_unit_structs", # stylistic
]

[env]
# Needed for musl builds so user doesn't have to install musl-tools.
CC_x86_64_unknown_linux_musl = { value = ".cargo/musl-gcc", force = true, relative = true }
CXX_x86_64_unknown_linux_musl = { value = ".cargo/musl-g++", force = true, relative = true }
7 changes: 7 additions & 0 deletions .cargo/musl-g++
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Wrapper for building with musl.
#
# See comments for musl-gcc in this repo.

g++ "$@"
13 changes: 13 additions & 0 deletions .cargo/musl-gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/sh

# Wrapper for building with musl.
#
# musl unfortunately requires a musl-enabled C compiler (musl-gcc) to be
# installed, which can be kind of a pain to get installed depending on the
# distro. That's not a very good user experience.
#
# The real musl-gcc wrapper sets the correct system include paths for linking
# with musl libc library. Since this is not actually used to link any binaries
# it should most likely work just fine.

gcc "$@"
20 changes: 20 additions & 0 deletions .gitlab/pipeline/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -503,3 +503,23 @@ cargo-hfuzz:
- cargo hfuzz build
- for target in $(cargo read-manifest | jq -r '.targets | .[] | .name'); do
cargo hfuzz run "$target" || { printf "fuzzing failure for %s\n" "$target"; exit 1; }; done

# cf https://github.com/paritytech/polkadot-sdk/issues/1652
test-syscalls:
stage: test
extends:
- .docker-env
- .common-refs
- .run-immediately
variables:
SKIP_WASM_BUILD: 1
script:
- cargo build --locked --profile production --target x86_64-unknown-linux-musl --bin polkadot-execute-worker --bin polkadot-prepare-worker
- cd polkadot/scripts/list-syscalls
- ./list-syscalls.rb ../../../target/x86_64-unknown-linux-musl/production/polkadot-execute-worker --only-used-syscalls | diff -u execute-worker-syscalls -
- ./list-syscalls.rb ../../../target/x86_64-unknown-linux-musl/production/polkadot-prepare-worker --only-used-syscalls | diff -u prepare-worker-syscalls -
after_script:
- if [[ "$CI_JOB_STATUS" == "failed" ]]; then
printf "The x86_64 syscalls used by the worker binaries have changed. Please review if this is expected and update polkadot/scripts/list-syscalls/*-worker-syscalls as needed.\n";
fi
allow_failure: true # TODO: remove this once we have an idea how often the syscall lists will change
74 changes: 74 additions & 0 deletions polkadot/scripts/list-syscalls/execute-worker-syscalls
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
0 (read)
1 (write)
2 (open)
3 (close)
4 (stat)
5 (fstat)
7 (poll)
8 (lseek)
9 (mmap)
10 (mprotect)
11 (munmap)
12 (brk)
13 (rt_sigaction)
14 (rt_sigprocmask)
15 (rt_sigreturn)
16 (ioctl)
19 (readv)
20 (writev)
24 (sched_yield)
25 (mremap)
28 (madvise)
39 (getpid)
41 (socket)
42 (connect)
45 (recvfrom)
46 (sendmsg)
53 (socketpair)
56 (clone)
60 (exit)
61 (wait4)
62 (kill)
72 (fcntl)
79 (getcwd)
80 (chdir)
82 (rename)
83 (mkdir)
87 (unlink)
89 (readlink)
96 (gettimeofday)
97 (getrlimit)
99 (sysinfo)
102 (getuid)
110 (getppid)
131 (sigaltstack)
140 (getpriority)
141 (setpriority)
144 (sched_setscheduler)
157 (prctl)
158 (arch_prctl)
165 (mount)
166 (umount2)
200 (tkill)
202 (futex)
204 (sched_getaffinity)
213 (epoll_create)
217 (getdents64)
218 (set_tid_address)
228 (clock_gettime)
230 (clock_nanosleep)
231 (exit_group)
232 (epoll_wait)
233 (epoll_ctl)
257 (openat)
262 (newfstatat)
263 (unlinkat)
272 (unshare)
273 (set_robust_list)
281 (epoll_pwait)
284 (eventfd)
290 (eventfd2)
291 (epoll_create1)
302 (prlimit64)
318 (getrandom)
319 (memfd_create)
Loading

0 comments on commit a1171e6

Please sign in to comment.