Skip to content

Commit 0594d03

Browse files
dgreidcrosvm LUCI
authored andcommitted
seccomp: Add riscv64 policies
Add a basic starting point for riscv64. constants generated with a slightly modified gerneate_constants script to run on a riscv64 native system as there isn't a chroot for that:) TEST: with the rest of the series applied, boot an ubuntu riscv64 VM using crosvm from a riscv64 host with sandboxeing emabled. Change-Id: I1ae7db4204df2ffdf1666ebc3e955a97d812f92a Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460940 Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
1 parent 3e431eb commit 0594d03

17 files changed

Lines changed: 2525 additions & 1 deletion

jail/seccomp/generate_constants.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ cleanup() {
2222
trap cleanup EXIT
2323

2424
# Create bindings for each platform
25-
for arch in "x86_64" "arm" "aarch64"; do
25+
for arch in "x86_64" "arm" "aarch64" "riscv64"; do
2626
BUILD_DIR="$TMP_DIR/$arch"
2727
mkdir -p "$BUILD_DIR"
2828
cd "$BUILD_DIR"
@@ -37,6 +37,9 @@ for arch in "x86_64" "arm" "aarch64"; do
3737
elif [ "$arch" = "aarch64" ]; then
3838
export CC="aarch64-linux-gnu-gcc"
3939
TARGET="aarch64-unknown-linux-gnu"
40+
elif [ "$arch" = "riscv64" ]; then
41+
export CC="riscv64-unknown-linux-gnu-gcc"
42+
TARGET="riscv64-unknown-linux-gnu"
4043
fi
4144

4245
"$MINIJAIL_DIR/gen_constants.sh" "libconstants.gen.c"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright 2019 The ChromiumOS Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
openat: 1
6+
7+
@include /usr/share/policy/crosvm/common_device.policy
8+
9+
pread64: 1
10+
pwrite64: 1
11+
statx: 1
12+
fstat: 1
13+
ioctl: arg1 == FIOCLEX
14+
getdents64: 1
15+
fdatasync: 1
16+
fsync: 1
17+
mkdirat: 1
18+
linkat: 1
19+
unlinkat: 1
20+
socket: arg0 == AF_UNIX
21+
utimensat: 1
22+
fchmod: 1
23+
fchmodat: 1
24+
fchown: 1
25+
fchownat: 1
26+
fstatfs: 1
27+
newfstatat: 1
28+
prctl: arg0 == PR_SET_NAME
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright 2019 The ChromiumOS Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
@include /usr/share/policy/crosvm/common_device.policy
6+
7+
openat: return ENOENT
8+
prctl: arg0 == PR_SET_NAME
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright 2020 The ChromiumOS Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
@include /usr/share/policy/crosvm/common_device.policy
6+
connect: 1
7+
geteuid: 1
8+
getsockname: 1
9+
prctl: arg0 == PR_SET_NAME
10+
socket: arg0 == AF_UNIX
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright 2019 The ChromiumOS Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
@include /usr/share/policy/crosvm/common_device.policy
6+
7+
fallocate: 1
8+
fdatasync: 1
9+
fstat: 1
10+
fsync: 1
11+
openat: return ENOENT
12+
newfstatat: 1
13+
preadv: 1
14+
pwritev: 1
15+
statx: 1
16+
timerfd_create: 1
17+
timerfd_gettime: 1
18+
timerfd_settime: 1
19+
prctl: arg0 == PR_SET_NAME
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright 2023 The ChromiumOS Authors
2+
# Use of this source code is governed by a BSD-style license that can be
3+
# found in the LICENSE file.
4+
5+
brk: 1
6+
clock_gettime: 1
7+
clone: arg0 & CLONE_THREAD
8+
clone3: 1
9+
close: 1
10+
dup3: 1
11+
dup: 1
12+
epoll_create1: 1
13+
epoll_ctl: 1
14+
epoll_pwait: 1
15+
eventfd2: 1
16+
exit: 1
17+
exit_group: 1
18+
ftruncate: 1
19+
futex: 1
20+
getcwd: 1
21+
getpid: 1
22+
gettid: 1
23+
gettimeofday: 1
24+
io_uring_setup: 1
25+
io_uring_register: 1
26+
io_uring_enter: 1
27+
kill: 1
28+
lseek: 1
29+
madvise: arg2 == MADV_DONTNEED || arg2 == MADV_DONTDUMP || arg2 == MADV_REMOVE || arg2 == MADV_MERGEABLE || arg2 == MADV_FREE
30+
membarrier: 1
31+
memfd_create: 1
32+
mmap: arg2 in ~PROT_EXEC
33+
mprotect: arg2 in ~PROT_EXEC
34+
mremap: 1
35+
munmap: 1
36+
nanosleep: 1
37+
clock_nanosleep: 1
38+
pipe2: 1
39+
ppoll: 1
40+
read: 1
41+
readlinkat: 1
42+
readv: 1
43+
recvfrom: 1
44+
recvmsg: 1
45+
restart_syscall: 1
46+
rseq: 1
47+
rt_sigaction: 1
48+
rt_sigprocmask: 1
49+
rt_sigreturn: 1
50+
sched_getaffinity: 1
51+
sched_yield: 1
52+
sendmsg: 1
53+
sendto: 1
54+
set_robust_list: 1
55+
sigaltstack: 1
56+
tgkill: arg2 == SIGABRT
57+
write: 1
58+
writev: 1
59+
fcntl: 1
60+
uname: 1

0 commit comments

Comments
 (0)