1
1
// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- extern crate libc;
5
-
6
4
use seccomp:: {
7
5
Error , SeccompAction , SeccompCmpOp , SeccompCondition , SeccompFilterContext , SeccompRule ,
8
6
} ;
9
7
10
- /// List of allowed syscalls, necessary for Firecracker to function correctly.
8
+ /// List of allowed syscalls necessary for correct functioning on x86_64 architectures.
9
+ /// Taken from the musl repo (i.e arch/x86_64/bits/syscall.h).
11
10
pub const ALLOWED_SYSCALLS : & [ i64 ] = & [
12
11
libc:: SYS_read ,
13
12
libc:: SYS_write ,
@@ -52,11 +51,11 @@ pub const ALLOWED_SYSCALLS: &[i64] = &[
52
51
libc:: SYS_getrandom ,
53
52
] ;
54
53
55
- // See /usr/ include/x86_64- linux-gnu/sys/epoll.h
54
+ // See include/uapi/ linux/eventpoll.h in the kernel code.
56
55
const EPOLL_CTL_ADD : u64 = 1 ;
57
56
const EPOLL_CTL_DEL : u64 = 2 ;
58
57
59
- // See /usr/ include/x86_64-linux-gnu/bits/ fcntl-linux.h
58
+ // See include/uapi/asm-generic/ fcntl.h in the kernel code.
60
59
const O_RDONLY : u64 = 0x00000000 ;
61
60
const O_RDWR : u64 = 0x00000002 ;
62
61
const O_NONBLOCK : u64 = 0x00004000 ;
@@ -66,7 +65,7 @@ const F_SETFD: u64 = 2;
66
65
const F_SETFL : u64 = 4 ;
67
66
const FD_CLOEXEC : u64 = 1 ;
68
67
69
- // See /usr/ include/linux/futex.h
68
+ // See include/uapi/ linux/futex.h in the kernel code.
70
69
const FUTEX_WAIT : u64 = 0 ;
71
70
const FUTEX_WAKE : u64 = 1 ;
72
71
const FUTEX_REQUEUE : u64 = 3 ;
@@ -75,14 +74,14 @@ const FUTEX_WAIT_PRIVATE: u64 = FUTEX_WAIT | FUTEX_PRIVATE_FLAG;
75
74
const FUTEX_WAKE_PRIVATE : u64 = FUTEX_WAKE | FUTEX_PRIVATE_FLAG ;
76
75
const FUTEX_REQUEUE_PRIVATE : u64 = FUTEX_REQUEUE | FUTEX_PRIVATE_FLAG ;
77
76
78
- // See /usr/ include/asm-generic/ioctls.h
77
+ // See include/uapi/ asm-generic/ioctls.h in the kernel code.
79
78
const TCGETS : u64 = 0x5401 ;
80
79
const TCSETS : u64 = 0x5402 ;
81
80
const TIOCGWINSZ : u64 = 0x5413 ;
82
81
const FIOCLEX : u64 = 0x5451 ;
83
82
const FIONBIO : u64 = 0x5421 ;
84
83
85
- // See /usr/ include/linux/kvm.h
84
+ // See include/uapi/ linux/if_tun.h in the kernel code.
86
85
const KVM_GET_API_VERSION : u64 = 0xae00 ;
87
86
const KVM_CREATE_VM : u64 = 0xae01 ;
88
87
const KVM_CHECK_EXTENSION : u64 = 0xae03 ;
@@ -105,21 +104,23 @@ const KVM_GET_SREGS: u64 = 0x8138ae83;
105
104
const KVM_GET_LAPIC : u64 = 0x8400ae8e ;
106
105
const KVM_GET_SUPPORTED_CPUID : u64 = 0xc008ae05 ;
107
106
108
- // See /usr/ include/linux/if_tun.h
107
+ // See include/uapi/ linux/if_tun.h in the kernel code.
109
108
const TUNSETIFF : u64 = 0x400454ca ;
110
109
const TUNSETOFFLOAD : u64 = 0x400454d0 ;
111
110
const TUNSETVNETHDRSZ : u64 = 0x400454d8 ;
112
111
113
- // See /usr/ include/asm-generic/mman-common.h and /usr/include/asm-generic/mman.h
112
+ // See include/uapi/ asm-generic/mman-common.h in the kernel code.
114
113
const PROT_NONE : u64 = 0x0 ;
115
114
const PROT_READ : u64 = 0x1 ;
116
115
const PROT_WRITE : u64 = 0x2 ;
116
+
117
+ // See include/uapi/asm-generic/mman.h in the kernel code.
117
118
const MAP_SHARED : u64 = 0x01 ;
118
119
const MAP_PRIVATE : u64 = 0x02 ;
119
120
const MAP_ANONYMOUS : u64 = 0x20 ;
120
121
const MAP_NORESERVE : u64 = 0x4000 ;
121
122
122
- // See /usr/ include/x86_64- linux-gnu/bits/ socket.h
123
+ // See include/linux/ socket.h in the kernel code.
123
124
const PF_LOCAL : u64 = 1 ;
124
125
125
126
/// The default context containing the white listed syscall rules required by `Firecracker` to
0 commit comments