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