1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 3 # Copyright (C) 2023 SUSE 4 # Author: Marcos Paulo de Souza <mpdesouza@suse 5 6 . $(dirname $0)/functions.sh 7 8 MOD_SYSCALL=test_klp_syscall 9 10 setup_config 11 12 # - Start _NRPROC processes calling getpid and 13 # getpid syscall. Check if all the processes 14 # state. 15 16 start_test "patch getpid syscall while being h 17 18 NPROC=$(getconf _NPROCESSORS_ONLN) 19 MAXPROC=128 20 21 for i in $(seq 1 $(($NPROC < $MAXPROC ? $NPROC 22 ./test_klp-call_getpid & 23 pids[$i]="$!" 24 done 25 26 pid_list=$(echo ${pids[@]} | tr ' ' ',') 27 load_lp $MOD_SYSCALL klp_pids=$pid_list 28 29 # wait for all tasks to transition to patched 30 loop_until 'grep -q '^0$' /sys/kernel/test_klp 31 32 pending_pids=$(cat /sys/kernel/test_klp_syscal 33 log "$MOD_SYSCALL: Remaining not livepatched p 34 35 for pid in ${pids[@]}; do 36 kill $pid || true 37 done 38 39 disable_lp $MOD_SYSCALL 40 unload_lp $MOD_SYSCALL 41 42 check_result "% insmod test_modules/$MOD_SYSCA 43 livepatch: enabling patch '$MOD_SYSCALL' 44 livepatch: '$MOD_SYSCALL': initializing patchi 45 livepatch: '$MOD_SYSCALL': starting patching t 46 livepatch: '$MOD_SYSCALL': completing patching 47 livepatch: '$MOD_SYSCALL': patching complete 48 $MOD_SYSCALL: Remaining not livepatched proces 49 % echo 0 > /sys/kernel/livepatch/$MOD_SYSCALL/ 50 livepatch: '$MOD_SYSCALL': initializing unpatc 51 livepatch: '$MOD_SYSCALL': starting unpatching 52 livepatch: '$MOD_SYSCALL': completing unpatchi 53 livepatch: '$MOD_SYSCALL': unpatching complete 54 % rmmod $MOD_SYSCALL" 55 56 exit 0
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.