@@ -375,12 +375,6 @@ cmd_help() {
375
375
echo " This should be used as the last step in every commit, to ensure that the"
376
376
echo " Rust style tests pass."
377
377
echo " "
378
- echo " generate_syscall_tables <version>"
379
- echo " Generates the syscall tables for seccompiler, according to a given kernel version."
380
- echo " Release candidate (rc) linux versions are not allowed."
381
- echo " Outputs a rust file for each supported arch: src/seccompiler/src/syscall_table/{arch}.rs"
382
- echo " Supported architectures: x86_64 and aarch64."
383
- echo " "
384
378
echo " install [-p|--path] [--debug|--release]"
385
379
echo " Install firecracker, jailer and seccomp binaries to /usr/local/bin or a given path."
386
380
echo " Only the musl linked binaries are supported."
@@ -1029,137 +1023,6 @@ cmd_checkenv() {
1029
1023
check_vulns
1030
1024
}
1031
1025
1032
- generate_syscall_table_x86_64 () {
1033
- path_to_rust_file=" $FC_ROOT_DIR /src/seccompiler/src/syscall_table/x86_64.rs"
1034
-
1035
- echo " $header " > $path_to_rust_file
1036
-
1037
- # the table for x86_64 is nicely formatted here: linux/arch/x86/entry/syscalls/syscall_64.tbl
1038
- cat linux/arch/x86/entry/syscalls/syscall_64.tbl | grep -v " ^#" | grep -v -e ' ^$' | \
1039
- awk ' {print $2,$3,$1}' | grep -v " ^x32" | \
1040
- awk ' {print " map.insert(\""$2"\".to_string(), "$3");"}' | sort >> $path_to_rust_file
1041
-
1042
- echo " $footer " >> $path_to_rust_file
1043
-
1044
- say " Generated at: $path_to_rust_file "
1045
- }
1046
-
1047
- generate_syscall_table_aarch64 () {
1048
- path_to_rust_file=" $FC_ROOT_DIR /src/seccompiler/src/syscall_table/aarch64.rs"
1049
-
1050
- # filter for substituting `#define`s that point to other macros;
1051
- # values taken from linux/include/uapi/asm-generic/unistd.h
1052
- replace+=' s/__NR3264_fadvise64/223/;'
1053
- replace+=' s/__NR3264_fcntl/25/;'
1054
- replace+=' s/__NR3264_fstatat/79/;'
1055
- replace+=' s/__NR3264_fstatfs/44/;'
1056
- replace+=' s/__NR3264_fstat/80/;'
1057
- replace+=' s/__NR3264_ftruncate/46/;'
1058
- replace+=' s/__NR3264_lseek/62/;'
1059
- replace+=' s/__NR3264_sendfile/71/;'
1060
- replace+=' s/__NR3264_statfs/43/;'
1061
- replace+=' s/__NR3264_truncate/45/;'
1062
- replace+=' s/__NR3264_mmap/222/;'
1063
-
1064
- echo " $header " > $path_to_rust_file
1065
-
1066
- # run the gcc command in the Docker container (to make sure that we have gcc installed)
1067
- # the aarch64 syscall table is not located in a .tbl file, like x86; we run gcc's
1068
- # pre-processor to extract the numeric constants from header files.
1069
- run_devctr \
1070
- --user " $( id -u) :$( id -g) " \
1071
- --workdir " $CTR_KERNEL_DIR " \
1072
- -- \
1073
- gcc -Ilinux/include/uapi -E -dM -D__ARCH_WANT_RENAMEAT\
1074
- -D__BITS_PER_LONG=64\
1075
- linux/arch/arm64/include/uapi/asm/unistd.h | \
1076
- grep " #define __NR_" | grep -v " __NR_syscalls" | \
1077
- grep -v " __NR_arch_specific_syscall" | \
1078
- awk -F ' __NR_' ' {print $2}' | \
1079
- sed $replace | \
1080
- awk ' { print " map.insert(\""$1"\".to_string(), "$2");" }' | \
1081
- sort -d >> $path_to_rust_file
1082
- ret=$?
1083
-
1084
- [ $ret -ne 0 ] && return $ret
1085
-
1086
- echo " $footer " >> $path_to_rust_file
1087
-
1088
- say " Generated at: $path_to_rust_file "
1089
- }
1090
-
1091
- cmd_generate_syscall_tables () {
1092
- # Parse any command line args.
1093
- while [ $# -gt 0 ]; do
1094
- case " $1 " in
1095
- " -h" |" --help" ) { cmd_help; exit 1; } ;;
1096
- * ) { kernel_version=" $1 " ; break ; } ;;
1097
- esac
1098
- shift
1099
- done
1100
-
1101
- validate_kernel_version " $kernel_version "
1102
-
1103
- kernel_major=v$( echo ${kernel_version} | cut -d . -f 1) .x
1104
- kernel_baseurl=https://www.kernel.org/pub/linux/kernel/${kernel_major}
1105
- kernel_archive=linux-${kernel_version} .tar.xz
1106
-
1107
- ensure_devctr
1108
-
1109
- # Create the kernel clone directory
1110
- rm -rf " $KERNEL_DIR "
1111
- create_dir " $KERNEL_DIR "
1112
- cd " $KERNEL_DIR "
1113
-
1114
- say " Fetching linux kernel..."
1115
-
1116
- # Get sha256 checksum.
1117
- curl -fsSLO ${kernel_baseurl} /sha256sums.asc && \
1118
- kernel_sha256=$( grep ${kernel_archive} sha256sums.asc | cut -d ' ' -f 1)
1119
- # Get kernel archive.
1120
- curl -fsSLO " $kernel_baseurl /$kernel_archive " && \
1121
- # Verify checksum.
1122
- echo " ${kernel_sha256} ${kernel_archive} " | sha256sum -c - && \
1123
- # Decompress the kernel source.
1124
- xz -d " ${kernel_archive} " && \
1125
- cat linux-${kernel_version} .tar | tar -x && mv linux-${kernel_version} linux
1126
-
1127
- ret=$?
1128
- [ $ret -ne 0 ] && return $ret
1129
-
1130
- # rust file header
1131
- read -r -d ' ' header << EOM
1132
- // Copyright $( date +" %Y" ) Amazon.com, Inc. or its affiliates. All Rights Reserved.
1133
- // SPDX-License-Identifier: Apache-2.0
1134
-
1135
- // This file is auto-generated by \` tools/devtool generate_syscall_tables\` .
1136
- // Do NOT manually edit!
1137
- // Generated at: $( date)
1138
- // Kernel version: $kernel_version
1139
-
1140
- use std::collections::HashMap;
1141
-
1142
- pub(crate) fn make_syscall_table(map: &mut HashMap<String, i64>) {
1143
- EOM
1144
-
1145
- # rust file footer
1146
- read -r -d ' ' footer << EOM
1147
- }
1148
-
1149
- EOM
1150
-
1151
- # generate syscall table for x86_64
1152
- say " Generating table for x86_64..."
1153
- generate_syscall_table_x86_64 $header $footer
1154
-
1155
- # generate syscall table for aarch64
1156
- say " Generating table for aarch64..."
1157
- generate_syscall_table_aarch64 $header $footer
1158
-
1159
- ret=$?
1160
- [ $ret -ne 0 ] && return $ret
1161
- }
1162
-
1163
1026
cmd_install () {
1164
1027
# By default we install release/musl binaries.
1165
1028
profile=" release"
0 commit comments