| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | |
| 3 | # |
| 4 | # libseccomp syscall validation script |
| 5 | # |
| 6 | # Copyright (c) 2014 Red Hat <[email protected]> |
| 7 | # Copyright (c) 2020 Cisco Systems, Inc. <[email protected]> |
| 8 | # Copyright (c) 2022 Microsoft Corporation. <[email protected]> |
| 9 | # |
| 10 | # Author: Paul Moore <[email protected]> |
| 11 | # |
| 12 | |
| 13 | # |
| 14 | # This library is free software; you can redistribute it and/or modify it |
| 15 | # under the terms of version 2.1 of the GNU Lesser General Public License as |
| 16 | # published by the Free Software Foundation. |
| 17 | # |
| 18 | # This library is distributed in the hope that it will be useful, but WITHOUT |
| 19 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 20 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License |
| 21 | # for more details. |
| 22 | # |
| 23 | # You should have received a copy of the GNU Lesser General Public License |
| 24 | # along with this library; if not, see <http://www.gnu.org/licenses>. |
| 25 | # |
| 26 | |
| 27 | LIB_SYS_DUMP="./arch-syscall-dump" |
| 28 | |
| 29 | #### |
| 30 | # functions |
| 31 | |
| 32 | # |
| 33 | # Dependency check |
| 34 | # |
| 35 | # Arguments: |
| 36 | # 1 Dependency to check for |
| 37 | # |
| 38 | function check_depsscip-shell shell libseccomp 2.6.0-2 check_deps().() { |
| 39 | [[ -z "$1" ]] && return |
| 40 | whichscip-shell system . . which. "$1" >& /dev/null |
| 41 | return $? |
| 42 | } |
| 43 | |
| 44 | # |
| 45 | # Dependency verification |
| 46 | # |
| 47 | # Arguments: |
| 48 | # 1 Dependency to check for |
| 49 | # |
| 50 | function verify_depsscip-shell shell libseccomp 2.6.0-2 verify_deps().() { |
| 51 | [[ -z "$1" ]] && return |
| 52 | if ! check_depsscip-shell shell libseccomp 2.6.0-2 check_deps(). "$1"; then |
| 53 | echoscip-shell system . . echo. "error: install \"$1\" and include it in your \$PATH" |
| 54 | exit 1 |
| 55 | fi |
| 56 | } |
| 57 | |
| 58 | # |
| 59 | # Print out script usage details |
| 60 | # |
| 61 | function usagescip-shell shell libseccomp 2.6.0-2 usage().() { |
| 62 | catscip-shell system . . cat. << EOF |
| 63 | usage: arch-syscall-validate [-h] [-c <file>] [-a <arch>] <kernel_directory> |
| 64 | |
| 65 | libseccomp syscall validation script |
| 66 | optional arguments: |
| 67 | -h show this help message and exit |
| 68 | -a architecture |
| 69 | -l output the library's syscall definitions |
| 70 | -s output the kernel's syscall definitions |
| 71 | -c <file> generate a CSV of the kernel's syscall definitions |
| 72 | EOF |
| 73 | } |
| 74 | |
| 75 | # |
| 76 | # Dump the kernel version |
| 77 | # |
| 78 | # Arguments: |
| 79 | # 1 path to the kernel source |
| 80 | # |
| 81 | # Dump the kernel's version information to stdout. |
| 82 | # |
| 83 | function kernel_versionscip-shell shell libseccomp 2.6.0-2 kernel_version().() { |
| 84 | local maj=$(catscip-shell system . . cat. $1/Makefile | \ |
| 85 | grep "^VERSION =" | awk -F "= " '{ print $2 }') |
| 86 | local min=$(catscip-shell system . . cat. $1/Makefile | \ |
| 87 | grep "^PATCHLEVEL =" | awk -F "= " '{ print $2 }') |
| 88 | local sub=$(catscip-shell system . . cat. $1/Makefile | \ |
| 89 | grep "^SUBLEVEL =" | awk -F "= " '{ print $2 }') |
| 90 | local xtr=$(catscip-shell system . . cat. $1/Makefile | \ |
| 91 | grep "^EXTRAVERSION =" | awk -F "= " '{ print $2 }') |
| 92 | echoscip-shell system . . echo. "${maj}.${min}.${sub}${xtr}" |
| 93 | } |
| 94 | |
| 95 | # |
| 96 | # Dump the library syscall table for a given architecture |
| 97 | # |
| 98 | # Arguments: |
| 99 | # 1 architecture |
| 100 | # 2 offset (optional) |
| 101 | # |
| 102 | # |
| 103 | # Dump the library's syscall table to stdout. |
| 104 | # |
| 105 | function dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch().() { |
| 106 | local offset_str="" |
| 107 | |
| 108 | [[ -z $1 ]] && return |
| 109 | |
| 110 | [[ -n $2 ]] && offset_str="-o $2" |
| 111 | $LIB_SYS_DUMP -a $1 $offset_str | sedscip-shell system . . sed. 's/\t/,/' | sortscip-shell system . . sort. |
| 112 | } |
| 113 | |
| 114 | # |
| 115 | # Mangle the library pseudo syscall values |
| 116 | # |
| 117 | # Arguments: |
| 118 | # 1 architecture |
| 119 | # |
| 120 | # Mangle the supplied pseudo syscall to match the system values |
| 121 | # |
| 122 | function mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall().() { |
| 123 | local sed_filter="" |
| 124 | |
| 125 | sed_filter+='s/accept4,-118/accept4,364/;' |
| 126 | sed_filter+='s/bind,-102/bind,361/;' |
| 127 | sed_filter+='s/connect,-103/connect,362/;' |
| 128 | sed_filter+='s/getpeername,-107/getpeername,368/;' |
| 129 | sed_filter+='s/getsockname,-106/getsockname,367/;' |
| 130 | sed_filter+='s/getsockopt,-115/getsockopt,365/;' |
| 131 | sed_filter+='s/listen,-104/listen,363/;' |
| 132 | sed_filter+='s/msgctl,-214/msgctl,402/;' |
| 133 | sed_filter+='s/msgget,-213/msgget,399/;' |
| 134 | sed_filter+='s/msgrcv,-212/msgrcv,401/;' |
| 135 | sed_filter+='s/msgsnd,-211/msgsnd,400/;' |
| 136 | sed_filter+='s/recvfrom,-112/recvfrom,371/;' |
| 137 | sed_filter+='s/recvmsg,-117/recvmsg,372/;' |
| 138 | sed_filter+='s/semctl,-203/semctl,394/;' |
| 139 | sed_filter+='s/semget,-202/semget,393/;' |
| 140 | sed_filter+='s/sendmsg,-116/sendmsg,370/;' |
| 141 | sed_filter+='s/sendto,-111/sendto,369/;' |
| 142 | sed_filter+='s/setsockopt,-114/setsockopt,366/;' |
| 143 | sed_filter+='s/shmat,-221/shmat,397/;' |
| 144 | sed_filter+='s/shmctl,-224/shmctl,396/;' |
| 145 | sed_filter+='s/shmdt,-222/shmdt,398/;' |
| 146 | sed_filter+='s/shmget,-223/shmget,395/;' |
| 147 | sed_filter+='s/shutdown,-113/shutdown,373/;' |
| 148 | sed_filter+='s/socket,-101/socket,359/;' |
| 149 | sed_filter+='s/socketpair,-108/socketpair,360/;' |
| 150 | |
| 151 | case $1 in |
| 152 | s390|s390x) |
| 153 | sed_filter+='s/recvmmsg,-119/recvmmsg,357/;' |
| 154 | sed_filter+='s/sendmmsg,-120/sendmmsg,358/;' |
| 155 | ;; |
| 156 | *) |
| 157 | sed_filter+='s/recvmmsg,-119/recvmmsg,337/;' |
| 158 | sed_filter+='s/sendmmsg,-120/sendmmsg,345/;' |
| 159 | ;; |
| 160 | esac |
| 161 | |
| 162 | sedscip-shell system . . sed. $sed_filter | sedscip-shell system . . sed. '/,-[0-9]\+$/dscip-shell filesystem . . `/,-[0-9]\+$/d`.' |
| 163 | } |
| 164 | |
| 165 | # |
| 166 | # Dump syscalls matching specified tags from the given syscall.tbl file |
| 167 | # |
| 168 | # Arguments: |
| 169 | # 1 path to the syscall.tbl file to dump |
| 170 | # (rest) tags to match (except "common" which is always included) |
| 171 | # |
| 172 | # Dump the matched syscall table entries to stdout. |
| 173 | # |
| 174 | function dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl().() { |
| 175 | local file="$1" |
| 176 | shift |
| 177 | |
| 178 | local tag |
| 179 | local tag_regexp='^(common' |
| 180 | for tag in "$@"; do |
| 181 | tag_regexp="${tag_regexp}|${tag}" |
| 182 | done |
| 183 | tag_regexp="${tag_regexp}) " |
| 184 | |
| 185 | catscip-shell system . . cat. "$file" | grepscip-shell system . . grep. -v '^#\|^$' | awkscip-shell system . . awk. '{ print $2,$3,$1 }' | \ |
| 186 | grep -E "$tag_regexp" | awkscip-shell system . . awk. '{ print $2","$3 }' | sortscip-shell system . . sort. | \ |
| 187 | grep -Ev '^(reserved|unused)[0-9]+,' |
| 188 | } |
| 189 | |
| 190 | # |
| 191 | # Dump the x86 system syscall table |
| 192 | # |
| 193 | # Arguments: |
| 194 | # 1 path to the kernel source |
| 195 | # |
| 196 | # Dump the architecture's syscall table to stdout. |
| 197 | # |
| 198 | function dump_sys_x86scip-shell shell libseccomp 2.6.0-2 dump_sys_x86().() { |
| 199 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/x86/entry/syscalls/syscall_32.tbl" i386 |
| 200 | } |
| 201 | |
| 202 | # |
| 203 | # Dump the x86 library syscall table |
| 204 | # |
| 205 | # Dump the library's syscall table to stdout. |
| 206 | # |
| 207 | function dump_lib_x86scip-shell shell libseccomp 2.6.0-2 dump_lib_x86().() { |
| 208 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). x86 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). x86 |
| 209 | } |
| 210 | |
| 211 | # |
| 212 | # Dump the x86_64 system syscall table |
| 213 | # |
| 214 | # Arguments: |
| 215 | # 1 path to the kernel source |
| 216 | # |
| 217 | # Dump the architecture's syscall table to stdout. |
| 218 | # |
| 219 | function dump_sys_x86_64scip-shell shell libseccomp 2.6.0-2 dump_sys_x86_64().() { |
| 220 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/x86/entry/syscalls/syscall_64.tbl" 64 |
| 221 | } |
| 222 | |
| 223 | # |
| 224 | # Dump the x86_64 library syscall table |
| 225 | # |
| 226 | # Dump the library's syscall table to stdout. |
| 227 | # |
| 228 | function dump_lib_x86_64scip-shell shell libseccomp 2.6.0-2 dump_lib_x86_64().() { |
| 229 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). x86_64 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). x86_64 |
| 230 | } |
| 231 | |
| 232 | # |
| 233 | # Dump the x32 system syscall table |
| 234 | # |
| 235 | # Arguments: |
| 236 | # 1 path to the kernel source |
| 237 | # |
| 238 | # Dump the architecture's syscall table to stdout. |
| 239 | # |
| 240 | function dump_sys_x32scip-shell shell libseccomp 2.6.0-2 dump_sys_x32().() { |
| 241 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/x86/entry/syscalls/syscall_64.tbl" x32 |
| 242 | } |
| 243 | |
| 244 | # |
| 245 | # Dump the x32 library syscall table |
| 246 | # |
| 247 | # Dump the library's syscall table to stdout. |
| 248 | # |
| 249 | function dump_lib_x32scip-shell shell libseccomp 2.6.0-2 dump_lib_x32().() { |
| 250 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). x32 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). x32 |
| 251 | } |
| 252 | |
| 253 | # |
| 254 | # Dump the arm system syscall table |
| 255 | # |
| 256 | # Arguments: |
| 257 | # 1 path to the kernel source |
| 258 | # |
| 259 | # Dump the architecture's syscall table to stdout. |
| 260 | # |
| 261 | function dump_sys_armscip-shell shell libseccomp 2.6.0-2 dump_sys_arm().() { |
| 262 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/arm/tools/syscall.tbl" eabi | (catscip-shell system . . cat. -; \ |
| 263 | (catscip-shell system . . cat. $1/arch/arm/include/uapi/asm/unistd.h | \ |
| 264 | grep "^#define __ARM_NR_" | \ |
| 265 | grep -v "^#define __ARM_NR_BASE" | \ |
| 266 | sed 's/#define __ARM_NR_\([a-z0-9_]*\)[ \t]\+(__ARM_NR_BASE+\(.*\))/\1 983040 + \2/' | \ |
| 267 | awk '{ print $1","$2+$4 }')) | sortscip-shell system . . sort. |
| 268 | } |
| 269 | |
| 270 | # |
| 271 | # Dump the arm library syscall table |
| 272 | # |
| 273 | # Dump the library's syscall table to stdout. |
| 274 | # |
| 275 | function dump_lib_armscip-shell shell libseccomp 2.6.0-2 dump_lib_arm().() { |
| 276 | # NOTE: arm_sync_file_range() and sync_file_range2() share values |
| 277 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). arm | sedscip-shell system . . sed. '/sync_file_range2,\+341/dscip-shell filesystem . . `/sync_file_range2,\+341/d`.' | \ |
| 278 | mangle_lib_syscall arm |
| 279 | } |
| 280 | |
| 281 | # |
| 282 | # Dump the aarch64 system syscall table |
| 283 | # |
| 284 | # Arguments: |
| 285 | # 1 path to the kernel source |
| 286 | # |
| 287 | # Dump the architecture's syscall table to stdout. |
| 288 | # |
| 289 | function dump_sys_aarch64scip-shell shell libseccomp 2.6.0-2 dump_sys_aarch64().() { |
| 290 | local syscall_tbl_file="$1/arch/arm64/tools/syscall_64.tbl" |
| 291 | if [[ -e $syscall_tbl_file ]]; then |
| 292 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$syscall_tbl_file" \ |
| 293 | 64 renameat rlimit memfd_secret |
| 294 | return |
| 295 | fi |
| 296 | |
| 297 | local sed_filter="" |
| 298 | |
| 299 | sed_filter+='s/__NR3264_statfs/43/;' |
| 300 | sed_filter+='s/__NR3264_ftruncate/46/;' |
| 301 | sed_filter+='s/__NR3264_truncate/45/;' |
| 302 | sed_filter+='s/__NR3264_lseek/62/;' |
| 303 | sed_filter+='s/__NR3264_sendfile/71/;' |
| 304 | sed_filter+='s/__NR3264_fstatat/79/;' |
| 305 | sed_filter+='s/__NR3264_fstatfs/44/;' |
| 306 | sed_filter+='s/__NR3264_fcntl/25/;' |
| 307 | sed_filter+='s/__NR3264_fadvise64/223/;' |
| 308 | sed_filter+='s/__NR3264_mmap/222/;' |
| 309 | sed_filter+='s/__NR3264_fstat/80/;' |
| 310 | sed_filter+='s/__NR3264_lstat/1039/;' |
| 311 | sed_filter+='s/__NR3264_stat/1038/;' |
| 312 | |
| 313 | gccscip-shell system . . gcc. -E -dM -I$1/include/uapi \ |
| 314 | -D__BITS_PER_LONG=64 -D__ARCH_WANT_RENAMEAT \ |
| 315 | -D__ARCH_WANT_NEW_STAT \ |
| 316 | $1/arch/arm64/include/uapi/asm/unistd.h | \ |
| 317 | grep "^#define __NR_" | \ |
| 318 | sed '/__NR_syscalls/dscip-shell filesystem . . `/__NR_syscalls/d`.' | \ |
| 319 | sed '/__NR_arch_specific_syscall/dscip-shell filesystem . . `/__NR_arch_specific_syscall/d`.' | \ |
| 320 | sed 's/#define[ \t]\+__NR_\([^ \t]\+\)[ \t]\+\(.*\)/\1,\2/' | \ |
| 321 | sed $sed_filter | sortscip-shell system . . sort. |
| 322 | } |
| 323 | |
| 324 | # |
| 325 | # Dump the aarch64 library syscall table |
| 326 | # |
| 327 | # Dump the library's syscall table to stdout. |
| 328 | # |
| 329 | function dump_lib_aarch64scip-shell shell libseccomp 2.6.0-2 dump_lib_aarch64().() { |
| 330 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). aarch64 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). aarch64 |
| 331 | } |
| 332 | |
| 333 | # |
| 334 | # Dump the loongarch64 syscall table |
| 335 | # |
| 336 | # Arguments: |
| 337 | # 1 path to the kernel source |
| 338 | # |
| 339 | # Dump the architecture's syscall table to stdout. |
| 340 | # |
| 341 | function dump_sys_loongarch64scip-shell shell libseccomp 2.6.0-2 dump_sys_loongarch64().() { |
| 342 | if [[ -e $1/arch/loongarch/kernel/Makefile.syscalls ]]; then |
| 343 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/scripts/syscall.tbl" 64 |
| 344 | return |
| 345 | fi |
| 346 | |
| 347 | local sed_filter="" |
| 348 | |
| 349 | sed_filter+='s/__NR3264_fadvise64/223/;' |
| 350 | sed_filter+='s/__NR3264_fcntl/25/;' |
| 351 | sed_filter+='s/__NR3264_fstatfs/44/;' |
| 352 | sed_filter+='s/__NR3264_ftruncate/46/;' |
| 353 | sed_filter+='s/__NR3264_lseek/62/;' |
| 354 | sed_filter+='s/__NR3264_mmap/222/;' |
| 355 | sed_filter+='s/__NR3264_sendfile/71/;' |
| 356 | sed_filter+='s/__NR3264_statfs/43/;' |
| 357 | sed_filter+='s/__NR3264_truncate/45/;' |
| 358 | |
| 359 | gccscip-shell system . . gcc. -E -dM -I$1/include/uapi \ |
| 360 | -D__BITS_PER_LONG=64 \ |
| 361 | -D__ARCH_WANT_SYS_CLONE \ |
| 362 | -D__ARCH_WANT_SYS_CLONE3 \ |
| 363 | $1/arch/loongarch/include/uapi/asm/unistd.h | \ |
| 364 | grep "^#define __NR_" | \ |
| 365 | sed '/__NR_syscalls/dscip-shell filesystem . . `/__NR_syscalls/d`.' | \ |
| 366 | sed '/__NR_arch_specific_syscall/dscip-shell filesystem . . `/__NR_arch_specific_syscall/d`.' | \ |
| 367 | sed 's/#define[ \t]\+__NR_\([^ \t]\+\)[ \t]\+\(.*\)/\1,\2/' | \ |
| 368 | sed $sed_filter | sortscip-shell system . . sort. |
| 369 | } |
| 370 | |
| 371 | # |
| 372 | # Dump the loongarch64 library syscall table |
| 373 | # |
| 374 | # Dump the library's syscall table to stdout. |
| 375 | # |
| 376 | function dump_lib_loongarch64scip-shell shell libseccomp 2.6.0-2 dump_lib_loongarch64().() { |
| 377 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). loongarch64 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). loongarch64 |
| 378 | } |
| 379 | |
| 380 | # Dump the m68k system syscall table |
| 381 | # |
| 382 | # Arguments: |
| 383 | # 1 path to the kernel source |
| 384 | # |
| 385 | # Dump the architecture's syscall table to stdout. |
| 386 | # |
| 387 | function dump_sys_m68kscip-shell shell libseccomp 2.6.0-2 dump_sys_m68k().() { |
| 388 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/m68k/kernel/syscalls/syscall.tbl" |
| 389 | } |
| 390 | |
| 391 | # |
| 392 | # Dump the m68k library syscall table |
| 393 | # |
| 394 | # Dump the library's syscall table to stdout. |
| 395 | # |
| 396 | function dump_lib_m68kscip-shell shell libseccomp 2.6.0-2 dump_lib_m68k().() { |
| 397 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). m68k | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). m68k |
| 398 | } |
| 399 | |
| 400 | # |
| 401 | # Dump the mips system syscall table |
| 402 | # |
| 403 | # Arguments: |
| 404 | # 1 path to the kernel source |
| 405 | # |
| 406 | # Dump the architecture's syscall table to stdout. |
| 407 | # |
| 408 | function dump_sys_mipsscip-shell shell libseccomp 2.6.0-2 dump_sys_mips().() { |
| 409 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/mips/kernel/syscalls/syscall_o32.tbl" o32 |
| 410 | } |
| 411 | |
| 412 | # |
| 413 | # Dump the mips library syscall table |
| 414 | # |
| 415 | # Dump the library's syscall table to stdout. |
| 416 | # |
| 417 | function dump_lib_mipsscip-shell shell libseccomp 2.6.0-2 dump_lib_mips().() { |
| 418 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). mips | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). mips |
| 419 | } |
| 420 | |
| 421 | # |
| 422 | # Dump the mips64 system syscall table |
| 423 | # |
| 424 | # Arguments: |
| 425 | # 1 path to the kernel source |
| 426 | # |
| 427 | # Dump the architecture's syscall table to stdout. |
| 428 | # |
| 429 | function dump_sys_mips64scip-shell shell libseccomp 2.6.0-2 dump_sys_mips64().() { |
| 430 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/mips/kernel/syscalls/syscall_n64.tbl" n64 |
| 431 | } |
| 432 | |
| 433 | # |
| 434 | # Dump the mips64 library syscall table |
| 435 | # |
| 436 | # Dump the library's syscall table to stdout. |
| 437 | # |
| 438 | function dump_lib_mips64scip-shell shell libseccomp 2.6.0-2 dump_lib_mips64().() { |
| 439 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). mips64 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). mips64 |
| 440 | } |
| 441 | |
| 442 | # |
| 443 | # Dump the mips64n32 system syscall table |
| 444 | # |
| 445 | # Arguments: |
| 446 | # 1 path to the kernel source |
| 447 | # |
| 448 | # Dump the architecture's syscall table to stdout. |
| 449 | # |
| 450 | function dump_sys_mips64n32scip-shell shell libseccomp 2.6.0-2 dump_sys_mips64n32().() { |
| 451 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/mips/kernel/syscalls/syscall_n32.tbl" n32 |
| 452 | } |
| 453 | |
| 454 | # |
| 455 | # Dump the mips64n32 library syscall table |
| 456 | # |
| 457 | # Dump the library's syscall table to stdout. |
| 458 | # |
| 459 | function dump_lib_mips64n32scip-shell shell libseccomp 2.6.0-2 dump_lib_mips64n32().() { |
| 460 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). mips64n32 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). mips64n32 |
| 461 | } |
| 462 | |
| 463 | # |
| 464 | # Dump the parisc system syscall table |
| 465 | # |
| 466 | # Arguments: |
| 467 | # 1 path to the kernel source |
| 468 | # |
| 469 | # Dump the architecture's syscall table to stdout. |
| 470 | # |
| 471 | function dump_sys_pariscscip-shell shell libseccomp 2.6.0-2 dump_sys_parisc().() { |
| 472 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/parisc/kernel/syscalls/syscall.tbl" 32 |
| 473 | } |
| 474 | |
| 475 | # |
| 476 | # Dump the parisc library syscall table |
| 477 | # |
| 478 | # Dump the library's syscall table to stdout. |
| 479 | # |
| 480 | function dump_lib_pariscscip-shell shell libseccomp 2.6.0-2 dump_lib_parisc().() { |
| 481 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). parisc | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). parisc |
| 482 | } |
| 483 | |
| 484 | # |
| 485 | # Dump the parisc64 system syscall table |
| 486 | # |
| 487 | # Arguments: |
| 488 | # 1 path to the kernel source |
| 489 | # |
| 490 | # Dump the architecture's syscall table to stdout. |
| 491 | # |
| 492 | function dump_sys_parisc64scip-shell shell libseccomp 2.6.0-2 dump_sys_parisc64().() { |
| 493 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/parisc/kernel/syscalls/syscall.tbl" 64 |
| 494 | } |
| 495 | |
| 496 | # |
| 497 | # Dump the parisc64 library syscall table |
| 498 | # |
| 499 | # Dump the library's syscall table to stdout. |
| 500 | # |
| 501 | function dump_lib_parisc64scip-shell shell libseccomp 2.6.0-2 dump_lib_parisc64().() { |
| 502 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). parisc64 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). parisc64 |
| 503 | } |
| 504 | |
| 505 | # |
| 506 | # Dump the ppc system syscall table |
| 507 | # |
| 508 | # Arguments: |
| 509 | # 1 path to the kernel source |
| 510 | # |
| 511 | # Dump the architecture's syscall table to stdout. |
| 512 | # |
| 513 | function dump_sys_ppcscip-shell shell libseccomp 2.6.0-2 dump_sys_ppc().() { |
| 514 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/powerpc/kernel/syscalls/syscall.tbl" \ |
| 515 | nospu 32 |
| 516 | } |
| 517 | |
| 518 | # |
| 519 | # Dump the ppc library syscall table |
| 520 | # |
| 521 | # Dump the library's syscall table to stdout. |
| 522 | # |
| 523 | function dump_lib_ppcscip-shell shell libseccomp 2.6.0-2 dump_lib_ppc().() { |
| 524 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). ppc | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). ppc |
| 525 | } |
| 526 | |
| 527 | # |
| 528 | # Dump the ppc64 system syscall table |
| 529 | # |
| 530 | # Arguments: |
| 531 | # 1 path to the kernel source |
| 532 | # |
| 533 | # Dump the architecture's syscall table to stdout. |
| 534 | # |
| 535 | function dump_sys_ppc64scip-shell shell libseccomp 2.6.0-2 dump_sys_ppc64().() { |
| 536 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/powerpc/kernel/syscalls/syscall.tbl" \ |
| 537 | nospu 64 |
| 538 | } |
| 539 | |
| 540 | # |
| 541 | # Dump the ppc64 library syscall table |
| 542 | # |
| 543 | # Dump the library's syscall table to stdout. |
| 544 | # |
| 545 | function dump_lib_ppc64scip-shell shell libseccomp 2.6.0-2 dump_lib_ppc64().() { |
| 546 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). ppc64 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). ppc64 |
| 547 | } |
| 548 | |
| 549 | # |
| 550 | # Dump the riscv64 system syscall table |
| 551 | # |
| 552 | # Arguments: |
| 553 | # 1 path to the kernel source |
| 554 | # |
| 555 | # Dump the architecture's syscall table to stdout. |
| 556 | # |
| 557 | function dump_sys_riscv64scip-shell shell libseccomp 2.6.0-2 dump_sys_riscv64().() { |
| 558 | if [[ -e $1/arch/riscv/kernel/Makefile.syscalls ]]; then |
| 559 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/scripts/syscall.tbl" \ |
| 560 | 64 riscv rlimit memfd_secret |
| 561 | return |
| 562 | fi |
| 563 | |
| 564 | local sed_filter="" |
| 565 | |
| 566 | sed_filter+='s/__NR3264_fadvise64/223/;' |
| 567 | sed_filter+='s/__NR3264_fcntl/25/;' |
| 568 | sed_filter+='s/__NR3264_fstatat/79/;' |
| 569 | sed_filter+='s/__NR3264_fstatfs/44/;' |
| 570 | sed_filter+='s/__NR3264_ftruncate/46/;' |
| 571 | sed_filter+='s/__NR3264_lseek/62/;' |
| 572 | sed_filter+='s/__NR3264_mmap/222/;' |
| 573 | sed_filter+='s/__NR3264_sendfile/71/;' |
| 574 | sed_filter+='s/__NR3264_statfs/43/;' |
| 575 | sed_filter+='s/__NR3264_truncate/45/;' |
| 576 | sed_filter+='s/__NR3264_fstat/80/;' |
| 577 | |
| 578 | gccscip-shell system . . gcc. -E -dM -I$1/include/uapi \ |
| 579 | -D__BITS_PER_LONG=64 -D__ARCH_WANT_NEW_STAT \ |
| 580 | $1/arch/riscv/include/uapi/asm/unistd.h | \ |
| 581 | grep "^#define __NR_" | \ |
| 582 | sed '/__NR_syscalls/dscip-shell filesystem . . `/__NR_syscalls/d`.' | \ |
| 583 | sed 's/(__NR_arch_specific_syscall + 15)/259/' | \ |
| 584 | sed '/__NR_arch_specific_syscall/dscip-shell filesystem . . `/__NR_arch_specific_syscall/d`.' | \ |
| 585 | sed 's/#define[ \t]\+__NR_\([^ \t]\+\)[ \t]\+\(.*\)/\1,\2/' | \ |
| 586 | sed $sed_filter | sortscip-shell system . . sort. |
| 587 | } |
| 588 | |
| 589 | # |
| 590 | # Dump the riscv64 library syscall table |
| 591 | # |
| 592 | # Dump the library's syscall table to stdout. |
| 593 | # |
| 594 | function dump_lib_riscv64scip-shell shell libseccomp 2.6.0-2 dump_lib_riscv64().() { |
| 595 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). riscv64 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). riscv64 |
| 596 | } |
| 597 | |
| 598 | # |
| 599 | # Dump the s390 system syscall table |
| 600 | # |
| 601 | # Arguments: |
| 602 | # 1 path to the kernel source |
| 603 | # |
| 604 | # Dump the architecture's syscall table to stdout. |
| 605 | # |
| 606 | function dump_sys_s390scip-shell shell libseccomp 2.6.0-2 dump_sys_s390().() { |
| 607 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/s390/kernel/syscalls/syscall.tbl" 32 |
| 608 | } |
| 609 | |
| 610 | # |
| 611 | # Dump the s390 library syscall table |
| 612 | # |
| 613 | # Dump the library's syscall table to stdout. |
| 614 | # |
| 615 | function dump_lib_s390scip-shell shell libseccomp 2.6.0-2 dump_lib_s390().() { |
| 616 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). s390 | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). s390 |
| 617 | } |
| 618 | |
| 619 | # |
| 620 | # Dump the s390x system syscall table |
| 621 | # |
| 622 | # Arguments: |
| 623 | # 1 path to the kernel source |
| 624 | # |
| 625 | # Dump the architecture's syscall table to stdout. |
| 626 | # |
| 627 | function dump_sys_s390xscip-shell shell libseccomp 2.6.0-2 dump_sys_s390x().() { |
| 628 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/s390/kernel/syscalls/syscall.tbl" 64 |
| 629 | } |
| 630 | |
| 631 | # |
| 632 | # Dump the s390x library syscall table |
| 633 | # |
| 634 | # Dump the library's syscall table to stdout. |
| 635 | # |
| 636 | function dump_lib_s390xscip-shell shell libseccomp 2.6.0-2 dump_lib_s390x().() { |
| 637 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). s390x | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). s390x |
| 638 | } |
| 639 | |
| 640 | # |
| 641 | # Dump the sh system syscall table |
| 642 | # |
| 643 | # Arguments: |
| 644 | # 1 path to the kernel source |
| 645 | # |
| 646 | # Dump the architecture's syscall table to stdout. |
| 647 | # |
| 648 | function dump_sys_shscip-shell shell libseccomp 2.6.0-2 dump_sys_sh().() { |
| 649 | dump_from_syscall_tblscip-shell shell libseccomp 2.6.0-2 dump_from_syscall_tbl(). "$1/arch/sh/kernel/syscalls/syscall.tbl" |
| 650 | } |
| 651 | |
| 652 | # |
| 653 | # Dump the sh library syscall table |
| 654 | # |
| 655 | # Dump the library's syscall table to stdout. |
| 656 | # |
| 657 | function dump_lib_shscip-shell shell libseccomp 2.6.0-2 dump_lib_sh().() { |
| 658 | dump_lib_archscip-shell shell libseccomp 2.6.0-2 dump_lib_arch(). sh | mangle_lib_syscallscip-shell shell libseccomp 2.6.0-2 mangle_lib_syscall(). sh |
| 659 | } |
| 660 | |
| 661 | # |
| 662 | # Dump the system syscall table |
| 663 | # |
| 664 | # Arguments: |
| 665 | # 1 architecture |
| 666 | # 2 path to the kernel source |
| 667 | # |
| 668 | # Dump the system's syscall table to stdout using the given architecture. |
| 669 | # |
| 670 | function dump_sysscip-shell shell libseccomp 2.6.0-2 dump_sys().() { |
| 671 | case $1 in |
| 672 | x86) |
| 673 | dump_sys_x86scip-shell shell libseccomp 2.6.0-2 dump_sys_x86(). "$2" |
| 674 | ;; |
| 675 | x86_64) |
| 676 | dump_sys_x86_64scip-shell shell libseccomp 2.6.0-2 dump_sys_x86_64(). "$2" |
| 677 | ;; |
| 678 | x32) |
| 679 | dump_sys_x32scip-shell shell libseccomp 2.6.0-2 dump_sys_x32(). "$2" |
| 680 | ;; |
| 681 | arm) |
| 682 | dump_sys_armscip-shell shell libseccomp 2.6.0-2 dump_sys_arm(). "$2" |
| 683 | ;; |
| 684 | aarch64) |
| 685 | dump_sys_aarch64scip-shell shell libseccomp 2.6.0-2 dump_sys_aarch64(). "$2" |
| 686 | ;; |
| 687 | loongarch64) |
| 688 | dump_sys_loongarch64scip-shell shell libseccomp 2.6.0-2 dump_sys_loongarch64(). "$2" |
| 689 | ;; |
| 690 | m68k) |
| 691 | dump_sys_m68kscip-shell shell libseccomp 2.6.0-2 dump_sys_m68k(). "$2" |
| 692 | ;; |
| 693 | mips) |
| 694 | dump_sys_mipsscip-shell shell libseccomp 2.6.0-2 dump_sys_mips(). "$2" |
| 695 | ;; |
| 696 | mips64) |
| 697 | dump_sys_mips64scip-shell shell libseccomp 2.6.0-2 dump_sys_mips64(). "$2" |
| 698 | ;; |
| 699 | mips64n32) |
| 700 | dump_sys_mips64n32scip-shell shell libseccomp 2.6.0-2 dump_sys_mips64n32(). "$2" |
| 701 | ;; |
| 702 | parisc) |
| 703 | dump_sys_pariscscip-shell shell libseccomp 2.6.0-2 dump_sys_parisc(). "$2" |
| 704 | ;; |
| 705 | parisc64) |
| 706 | dump_sys_parisc64scip-shell shell libseccomp 2.6.0-2 dump_sys_parisc64(). "$2" |
| 707 | ;; |
| 708 | ppc) |
| 709 | dump_sys_ppcscip-shell shell libseccomp 2.6.0-2 dump_sys_ppc(). "$2" |
| 710 | ;; |
| 711 | ppc64) |
| 712 | dump_sys_ppc64scip-shell shell libseccomp 2.6.0-2 dump_sys_ppc64(). "$2" |
| 713 | ;; |
| 714 | riscv64) |
| 715 | dump_sys_riscv64scip-shell shell libseccomp 2.6.0-2 dump_sys_riscv64(). "$2" |
| 716 | ;; |
| 717 | s390) |
| 718 | dump_sys_s390scip-shell shell libseccomp 2.6.0-2 dump_sys_s390(). "$2" |
| 719 | ;; |
| 720 | s390x) |
| 721 | dump_sys_s390xscip-shell shell libseccomp 2.6.0-2 dump_sys_s390x(). "$2" |
| 722 | ;; |
| 723 | sh) |
| 724 | dump_sys_shscip-shell shell libseccomp 2.6.0-2 dump_sys_sh(). "$2" |
| 725 | ;; |
| 726 | *) |
| 727 | echoscip-shell system . . echo. "" |
| 728 | return 1 |
| 729 | ;; |
| 730 | esac |
| 731 | |
| 732 | return 0 |
| 733 | } |
| 734 | |
| 735 | # |
| 736 | # Dump the library syscall table |
| 737 | # |
| 738 | # Arguments: |
| 739 | # 1 architecture |
| 740 | # |
| 741 | # Dump the library's syscall table to stdout using the given architecture. |
| 742 | # |
| 743 | function dump_libscip-shell shell libseccomp 2.6.0-2 dump_lib().() { |
| 744 | case $1 in |
| 745 | x86) |
| 746 | dump_lib_x86scip-shell shell libseccomp 2.6.0-2 dump_lib_x86(). |
| 747 | ;; |
| 748 | x86_64) |
| 749 | dump_lib_x86_64scip-shell shell libseccomp 2.6.0-2 dump_lib_x86_64(). |
| 750 | ;; |
| 751 | x32) |
| 752 | dump_lib_x32scip-shell shell libseccomp 2.6.0-2 dump_lib_x32(). |
| 753 | ;; |
| 754 | arm) |
| 755 | dump_lib_armscip-shell shell libseccomp 2.6.0-2 dump_lib_arm(). |
| 756 | ;; |
| 757 | aarch64) |
| 758 | dump_lib_aarch64scip-shell shell libseccomp 2.6.0-2 dump_lib_aarch64(). |
| 759 | ;; |
| 760 | loongarch64) |
| 761 | dump_lib_loongarch64scip-shell shell libseccomp 2.6.0-2 dump_lib_loongarch64(). |
| 762 | ;; |
| 763 | m68k) |
| 764 | dump_lib_m68kscip-shell shell libseccomp 2.6.0-2 dump_lib_m68k(). |
| 765 | ;; |
| 766 | mips) |
| 767 | dump_lib_mipsscip-shell shell libseccomp 2.6.0-2 dump_lib_mips(). |
| 768 | ;; |
| 769 | mips64) |
| 770 | dump_lib_mips64scip-shell shell libseccomp 2.6.0-2 dump_lib_mips64(). |
| 771 | ;; |
| 772 | mips64n32) |
| 773 | dump_lib_mips64n32scip-shell shell libseccomp 2.6.0-2 dump_lib_mips64n32(). |
| 774 | ;; |
| 775 | parisc) |
| 776 | dump_lib_pariscscip-shell shell libseccomp 2.6.0-2 dump_lib_parisc(). |
| 777 | ;; |
| 778 | parisc64) |
| 779 | dump_lib_parisc64scip-shell shell libseccomp 2.6.0-2 dump_lib_parisc64(). |
| 780 | ;; |
| 781 | ppc) |
| 782 | dump_lib_ppcscip-shell shell libseccomp 2.6.0-2 dump_lib_ppc(). |
| 783 | ;; |
| 784 | ppc64) |
| 785 | dump_lib_ppc64scip-shell shell libseccomp 2.6.0-2 dump_lib_ppc64(). |
| 786 | ;; |
| 787 | riscv64) |
| 788 | dump_lib_riscv64scip-shell shell libseccomp 2.6.0-2 dump_lib_riscv64(). |
| 789 | ;; |
| 790 | s390) |
| 791 | dump_lib_s390scip-shell shell libseccomp 2.6.0-2 dump_lib_s390(). |
| 792 | ;; |
| 793 | s390x) |
| 794 | dump_lib_s390xscip-shell shell libseccomp 2.6.0-2 dump_lib_s390x(). |
| 795 | ;; |
| 796 | sh) |
| 797 | dump_lib_shscip-shell shell libseccomp 2.6.0-2 dump_lib_sh(). |
| 798 | ;; |
| 799 | *) |
| 800 | echoscip-shell system . . echo. "" |
| 801 | return 1 |
| 802 | ;; |
| 803 | esac |
| 804 | |
| 805 | return 0 |
| 806 | } |
| 807 | |
| 808 | # |
| 809 | # Generate the syscall csv file |
| 810 | # |
| 811 | # Arguments: |
| 812 | # 1 path to the kernel source |
| 813 | # 2 "sys" or "lib" depending on the syscall list to use |
| 814 | # 3 csv file to use as input for saved fields |
| 815 | # |
| 816 | # Generate a syscall csv file from the given kernel sources. |
| 817 | # |
| 818 | function gen_csvscip-shell shell libseccomp 2.6.0-2 gen_csv().() { |
| 819 | |
| 820 | # sanity checks |
| 821 | [[ -z $1 ]] && return |
| 822 | [[ $2 != "sys" && $2 != "lib" ]] && return |
| 823 | |
| 824 | # abi list |
| 825 | # NOTE: the ordering here is dependent on the layout of the |
| 826 | # arch_syscall_table struct in syscalls.h - BEWARE! |
| 827 | abi_list="" |
| 828 | abi_list+=" x86 x86_64 x32" |
| 829 | abi_list+=" arm aarch64" |
| 830 | abi_list+=" loongarch64" |
| 831 | abi_list+=" m68k" |
| 832 | abi_list+=" mips mips64 mips64n32" |
| 833 | abi_list+=" parisc parisc64" |
| 834 | abi_list+=" ppc ppc64" |
| 835 | abi_list+=" riscv64" |
| 836 | abi_list+=" s390 s390x" |
| 837 | abi_list+=" sh" |
| 838 | |
| 839 | # read the csv to get the existing data |
| 840 | local -A csv |
| 841 | local csv_has_kver=0 |
| 842 | local csv_input="$3" |
| 843 | [[ ! -e "$3" ]] && csv_input=/dev/nullscip-shell filesystem . . `/dev/null`. |
| 844 | grepscip-shell system . . grep. -q "KV_" "$csv_input" && csv_has_kver=1 |
| 845 | while read line; do |
| 846 | sc=$(echoscip-shell system . . echo. $line | cutscip-shell system . . cut. -d, -f 1) |
| 847 | local field=2 |
| 848 | for abi in $abi_list; do |
| 849 | csv[$sc,$abi]=$(echoscip-shell system . . echo. $line | cutscip-shell system . . cut. -d, -f $field) |
| 850 | ((field++)) |
| 851 | if [[ $csv_has_kver -eq 1 ]]; then |
| 852 | csv[$sc,${abi}_KVER]=$(echoscip-shell system . . echo. $line | \ |
| 853 | cut -d, -f $field) |
| 854 | ((field++)) |
| 855 | fi |
| 856 | done |
| 857 | done < <(sedscip-shell system . . sed. 's/#.*//;/^[ \t]*$/d' "$csv_input") |
| 858 | |
| 859 | # get the full syscall list |
| 860 | for abi in $abi_list; do |
| 861 | eval output_$abi=$(mktempscip-shell system . . mktemp. -t syscall_validate_XXXXXX) |
| 862 | dump_$2_$abi "$1" > $(eval echo $`eval echo output_$abi`) |
| 863 | done |
| 864 | sc_list=$( (for abi in $abi_list; do |
| 865 | catscip-shell system . . cat. $(eval echo $`eval echo output_$abi`); |
| 866 | done) | awkscip-shell system . . awk. -F "," '{ print $1 }' | sortscip-shell system . . sort. -u) |
| 867 | |
| 868 | # redirect the subshell to the csv file |
| 869 | ( |
| 870 | # output a simple header |
| 871 | prscip-shell system . . printf.intfscip-shell system . . printf. "#syscallscip-shell shell libseccomp 2.6.0-2 kernel_version(). (v%s %s)" \ |
| 872 | "$(kernel_version "$1")" "$(TZ=UTC datescip-shell system . . date. "+%Y-%m-%d")" |
| 873 | for abi in $abi_list; do |
| 874 | printfscip-shell system . . printf. ",%s,%s_kver" $abi $abi |
| 875 | done |
| 876 | printfscip-shell system . . printf. "\n" |
| 877 | |
| 878 | # output the syscall csv details |
| 879 | for sc in $sc_list; do |
| 880 | printfscip-shell system . . printf. "%s" $sc |
| 881 | for abi in $abi_list; do |
| 882 | num=$(grepscip-shell system . . grep. "^$sc," \ |
| 883 | $(eval echo $`eval echo output_$abi`) | \ |
| 884 | awk -F "," '{ print $2 }' ) |
| 885 | kver=${csv[$sc,${abi}_KVER]} |
| 886 | [[ -z $num ]] && num="PNR" |
| 887 | [[ -z $kver ]] && kver="KV_UNDEF" |
| 888 | printfscip-shell system . . printf. ",%s,%s" $num $kver |
| 889 | done |
| 890 | printfscip-shell system . . printf. "\n" |
| 891 | done |
| 892 | ) > "$3" |
| 893 | |
| 894 | # cleanup |
| 895 | for abi in $abi_list; do |
| 896 | rmscip-shell system . . rm. -f $(eval echo $`eval echo output_$abi`) |
| 897 | done |
| 898 | } |
| 899 | |
| 900 | #### |
| 901 | # main |
| 902 | |
| 903 | verify_depsscip-shell shell libseccomp 2.6.0-2 verify_deps(). diff |
| 904 | verify_depsscip-shell shell libseccomp 2.6.0-2 verify_deps(). gcc |
| 905 | verify_depsscip-shell shell libseccomp 2.6.0-2 verify_deps(). grep |
| 906 | verify_depsscip-shell shell libseccomp 2.6.0-2 verify_deps(). mktemp |
| 907 | verify_depsscip-shell shell libseccomp 2.6.0-2 verify_deps(). sed |
| 908 | |
| 909 | opt_arches="" |
| 910 | opt_csv="" |
| 911 | opt_sys=0 |
| 912 | opt_lib=0 |
| 913 | |
| 914 | while getopts "a:c:slh" opt; do |
| 915 | case $opt in |
| 916 | a) |
| 917 | opt_arches+="$OPTARG " |
| 918 | ;; |
| 919 | c) |
| 920 | opt_csv="$OPTARG" |
| 921 | ;; |
| 922 | s) |
| 923 | opt_sys=1 |
| 924 | opt_lib=0 |
| 925 | ;; |
| 926 | l) |
| 927 | opt_sys=0 |
| 928 | opt_lib=1 |
| 929 | ;; |
| 930 | h|*) |
| 931 | usagescip-shell shell libseccomp 2.6.0-2 usage(). |
| 932 | exit 1 |
| 933 | ;; |
| 934 | esac |
| 935 | done |
| 936 | shift $(($OPTIND - 1)) |
| 937 | |
| 938 | # defaults |
| 939 | if [[ $opt_arches == "" ]]; then |
| 940 | opt_arches=" \ |
| 941 | x86 x86_64 x32 \ |
| 942 | arm aarch64 \ |
| 943 | loongarch64 \ |
| 944 | m68k \ |
| 945 | mips mips64 mips64n32 \ |
| 946 | parisc parisc64 \ |
| 947 | ppc ppc64 \ |
| 948 | s390 s390x \ |
| 949 | sh" |
| 950 | fi |
| 951 | |
| 952 | # sanity checks |
| 953 | kernel_dir="$1" |
| 954 | if [[ -z $kernel_dir ]]; then |
| 955 | usagescip-shell shell libseccomp 2.6.0-2 usage(). |
| 956 | exit 1 |
| 957 | fi |
| 958 | if [[ ! -d $kernel_dir ]]; then |
| 959 | echoscip-shell system . . echo. "error: \"$1\" is not a valid directory" |
| 960 | exit 1 |
| 961 | fi |
| 962 | |
| 963 | if [[ ! -x "$LIB_SYS_DUMP" ]]; then |
| 964 | echoscip-shell system . . echo. "error: \"$LIB_SYS_DUMP\" is not present" |
| 965 | exit 1 |
| 966 | fi |
| 967 | |
| 968 | # generate some temp files |
| 969 | tmp_lib=$(mktempscip-shell system . . mktemp. -t syscall_validate_XXXXXX) |
| 970 | tmp_sys=$(mktempscip-shell system . . mktemp. -t syscall_validate_XXXXXX) |
| 971 | |
| 972 | if [[ -n $opt_csv ]]; then |
| 973 | # generate the syscall csv file |
| 974 | if [[ $opt_lib -eq 1 ]]; then |
| 975 | gen_csvscip-shell shell libseccomp 2.6.0-2 gen_csv(). $kernel_dir "lib" $opt_csv |
| 976 | else |
| 977 | gen_csvscip-shell shell libseccomp 2.6.0-2 gen_csv(). $kernel_dir "sys" $opt_csv |
| 978 | fi |
| 979 | else |
| 980 | # loop through the architectures and compare |
| 981 | for i in $opt_arches; do |
| 982 | # dump the syscall tables |
| 983 | dump_libscip-shell shell libseccomp 2.6.0-2 dump_lib(). $i > $tmp_lib |
| 984 | if [[ $? -ne 0 ]]; then |
| 985 | echoscip-shell system . . echo. "error: unknown arch $i" |
| 986 | exit 1 |
| 987 | fi |
| 988 | dump_sysscip-shell shell libseccomp 2.6.0-2 dump_sys(). $i "$kernel_dir" > $tmp_sys |
| 989 | if [[ $? -ne 0 ]]; then |
| 990 | echoscip-shell system . . echo. "error: unknown arch $i" |
| 991 | exit 1 |
| 992 | fi |
| 993 | |
| 994 | if [[ $opt_lib -eq 1 ]]; then |
| 995 | catscip-shell system . . cat. $tmp_lib |
| 996 | elif [[ $opt_sys -eq 1 ]]; then |
| 997 | catscip-shell system . . cat. $tmp_sys |
| 998 | else |
| 999 | # compare the lib and sys output |
| 1000 | diffscip-shell system . . diff. -u --label="$i [library]" $tmp_lib \ |
| 1001 | --label "$i [system]" $tmp_sys |
| 1002 | fi |
| 1003 | done |
| 1004 | fi |
| 1005 | |
| 1006 | # cleanup and exit |
| 1007 | rmscip-shell system . . rm. -f $tmp_lib $tmp_sys |
| 1008 | |
| 1009 | exit 0 |