1 #!/bin/bash 1 #!/bin/bash 2 # SPDX-License-Identifier: GPL-2.0 2 # SPDX-License-Identifier: GPL-2.0 3 # Copyright (C) 2019 SUSE 3 # Copyright (C) 2019 SUSE 4 4 5 . $(dirname $0)/functions.sh 5 . $(dirname $0)/functions.sh 6 6 7 MOD_LIVEPATCH=test_klp_state 7 MOD_LIVEPATCH=test_klp_state 8 MOD_LIVEPATCH2=test_klp_state2 8 MOD_LIVEPATCH2=test_klp_state2 9 MOD_LIVEPATCH3=test_klp_state3 9 MOD_LIVEPATCH3=test_klp_state3 10 10 11 setup_config 11 setup_config 12 12 13 13 14 # Load and remove a module that modifies the s 14 # Load and remove a module that modifies the system state 15 15 16 start_test "system state modification" 16 start_test "system state modification" 17 17 18 load_lp $MOD_LIVEPATCH 18 load_lp $MOD_LIVEPATCH 19 disable_lp $MOD_LIVEPATCH 19 disable_lp $MOD_LIVEPATCH 20 unload_lp $MOD_LIVEPATCH 20 unload_lp $MOD_LIVEPATCH 21 21 22 check_result "% insmod test_modules/$MOD_LIVEP 22 check_result "% insmod test_modules/$MOD_LIVEPATCH.ko 23 livepatch: enabling patch '$MOD_LIVEPATCH' 23 livepatch: enabling patch '$MOD_LIVEPATCH' 24 livepatch: '$MOD_LIVEPATCH': initializing patc 24 livepatch: '$MOD_LIVEPATCH': initializing patching transition 25 $MOD_LIVEPATCH: pre_patch_callback: vmlinux 25 $MOD_LIVEPATCH: pre_patch_callback: vmlinux 26 $MOD_LIVEPATCH: allocate_loglevel_state: alloc 26 $MOD_LIVEPATCH: allocate_loglevel_state: allocating space to store console_loglevel 27 livepatch: '$MOD_LIVEPATCH': starting patching 27 livepatch: '$MOD_LIVEPATCH': starting patching transition 28 livepatch: '$MOD_LIVEPATCH': completing patchi 28 livepatch: '$MOD_LIVEPATCH': completing patching transition 29 $MOD_LIVEPATCH: post_patch_callback: vmlinux 29 $MOD_LIVEPATCH: post_patch_callback: vmlinux 30 $MOD_LIVEPATCH: fix_console_loglevel: fixing c 30 $MOD_LIVEPATCH: fix_console_loglevel: fixing console_loglevel 31 livepatch: '$MOD_LIVEPATCH': patching complete 31 livepatch: '$MOD_LIVEPATCH': patching complete 32 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATC 32 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled 33 livepatch: '$MOD_LIVEPATCH': initializing unpa 33 livepatch: '$MOD_LIVEPATCH': initializing unpatching transition 34 $MOD_LIVEPATCH: pre_unpatch_callback: vmlinux 34 $MOD_LIVEPATCH: pre_unpatch_callback: vmlinux 35 $MOD_LIVEPATCH: restore_console_loglevel: rest 35 $MOD_LIVEPATCH: restore_console_loglevel: restoring console_loglevel 36 livepatch: '$MOD_LIVEPATCH': starting unpatchi 36 livepatch: '$MOD_LIVEPATCH': starting unpatching transition 37 livepatch: '$MOD_LIVEPATCH': completing unpatc 37 livepatch: '$MOD_LIVEPATCH': completing unpatching transition 38 $MOD_LIVEPATCH: post_unpatch_callback: vmlinux 38 $MOD_LIVEPATCH: post_unpatch_callback: vmlinux 39 $MOD_LIVEPATCH: free_loglevel_state: freeing s 39 $MOD_LIVEPATCH: free_loglevel_state: freeing space for the stored console_loglevel 40 livepatch: '$MOD_LIVEPATCH': unpatching comple 40 livepatch: '$MOD_LIVEPATCH': unpatching complete 41 % rmmod $MOD_LIVEPATCH" 41 % rmmod $MOD_LIVEPATCH" 42 42 43 43 44 # Take over system state change by a cumulativ 44 # Take over system state change by a cumulative patch 45 45 46 start_test "taking over system state modificat 46 start_test "taking over system state modification" 47 47 48 load_lp $MOD_LIVEPATCH 48 load_lp $MOD_LIVEPATCH 49 load_lp $MOD_LIVEPATCH2 49 load_lp $MOD_LIVEPATCH2 50 unload_lp $MOD_LIVEPATCH 50 unload_lp $MOD_LIVEPATCH 51 disable_lp $MOD_LIVEPATCH2 51 disable_lp $MOD_LIVEPATCH2 52 unload_lp $MOD_LIVEPATCH2 52 unload_lp $MOD_LIVEPATCH2 53 53 54 check_result "% insmod test_modules/$MOD_LIVEP 54 check_result "% insmod test_modules/$MOD_LIVEPATCH.ko 55 livepatch: enabling patch '$MOD_LIVEPATCH' 55 livepatch: enabling patch '$MOD_LIVEPATCH' 56 livepatch: '$MOD_LIVEPATCH': initializing patc 56 livepatch: '$MOD_LIVEPATCH': initializing patching transition 57 $MOD_LIVEPATCH: pre_patch_callback: vmlinux 57 $MOD_LIVEPATCH: pre_patch_callback: vmlinux 58 $MOD_LIVEPATCH: allocate_loglevel_state: alloc 58 $MOD_LIVEPATCH: allocate_loglevel_state: allocating space to store console_loglevel 59 livepatch: '$MOD_LIVEPATCH': starting patching 59 livepatch: '$MOD_LIVEPATCH': starting patching transition 60 livepatch: '$MOD_LIVEPATCH': completing patchi 60 livepatch: '$MOD_LIVEPATCH': completing patching transition 61 $MOD_LIVEPATCH: post_patch_callback: vmlinux 61 $MOD_LIVEPATCH: post_patch_callback: vmlinux 62 $MOD_LIVEPATCH: fix_console_loglevel: fixing c 62 $MOD_LIVEPATCH: fix_console_loglevel: fixing console_loglevel 63 livepatch: '$MOD_LIVEPATCH': patching complete 63 livepatch: '$MOD_LIVEPATCH': patching complete 64 % insmod test_modules/$MOD_LIVEPATCH2.ko 64 % insmod test_modules/$MOD_LIVEPATCH2.ko 65 livepatch: enabling patch '$MOD_LIVEPATCH2' 65 livepatch: enabling patch '$MOD_LIVEPATCH2' 66 livepatch: '$MOD_LIVEPATCH2': initializing pat 66 livepatch: '$MOD_LIVEPATCH2': initializing patching transition 67 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 67 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 68 $MOD_LIVEPATCH2: allocate_loglevel_state: spac 68 $MOD_LIVEPATCH2: allocate_loglevel_state: space to store console_loglevel already allocated 69 livepatch: '$MOD_LIVEPATCH2': starting patchin 69 livepatch: '$MOD_LIVEPATCH2': starting patching transition 70 livepatch: '$MOD_LIVEPATCH2': completing patch 70 livepatch: '$MOD_LIVEPATCH2': completing patching transition 71 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 71 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 72 $MOD_LIVEPATCH2: fix_console_loglevel: taking 72 $MOD_LIVEPATCH2: fix_console_loglevel: taking over the console_loglevel change 73 livepatch: '$MOD_LIVEPATCH2': patching complet 73 livepatch: '$MOD_LIVEPATCH2': patching complete 74 % rmmod $MOD_LIVEPATCH 74 % rmmod $MOD_LIVEPATCH 75 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATC 75 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH2/enabled 76 livepatch: '$MOD_LIVEPATCH2': initializing unp 76 livepatch: '$MOD_LIVEPATCH2': initializing unpatching transition 77 $MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux 77 $MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux 78 $MOD_LIVEPATCH2: restore_console_loglevel: res 78 $MOD_LIVEPATCH2: restore_console_loglevel: restoring console_loglevel 79 livepatch: '$MOD_LIVEPATCH2': starting unpatch 79 livepatch: '$MOD_LIVEPATCH2': starting unpatching transition 80 livepatch: '$MOD_LIVEPATCH2': completing unpat 80 livepatch: '$MOD_LIVEPATCH2': completing unpatching transition 81 $MOD_LIVEPATCH2: post_unpatch_callback: vmlinu 81 $MOD_LIVEPATCH2: post_unpatch_callback: vmlinux 82 $MOD_LIVEPATCH2: free_loglevel_state: freeing 82 $MOD_LIVEPATCH2: free_loglevel_state: freeing space for the stored console_loglevel 83 livepatch: '$MOD_LIVEPATCH2': unpatching compl 83 livepatch: '$MOD_LIVEPATCH2': unpatching complete 84 % rmmod $MOD_LIVEPATCH2" 84 % rmmod $MOD_LIVEPATCH2" 85 85 86 86 87 # Take over system state change by a cumulativ 87 # Take over system state change by a cumulative patch 88 88 89 start_test "compatible cumulative livepatches" 89 start_test "compatible cumulative livepatches" 90 90 91 load_lp $MOD_LIVEPATCH2 91 load_lp $MOD_LIVEPATCH2 92 load_lp $MOD_LIVEPATCH3 92 load_lp $MOD_LIVEPATCH3 93 unload_lp $MOD_LIVEPATCH2 93 unload_lp $MOD_LIVEPATCH2 94 load_lp $MOD_LIVEPATCH2 94 load_lp $MOD_LIVEPATCH2 95 disable_lp $MOD_LIVEPATCH2 95 disable_lp $MOD_LIVEPATCH2 96 unload_lp $MOD_LIVEPATCH2 96 unload_lp $MOD_LIVEPATCH2 97 unload_lp $MOD_LIVEPATCH3 97 unload_lp $MOD_LIVEPATCH3 98 98 99 check_result "% insmod test_modules/$MOD_LIVEP 99 check_result "% insmod test_modules/$MOD_LIVEPATCH2.ko 100 livepatch: enabling patch '$MOD_LIVEPATCH2' 100 livepatch: enabling patch '$MOD_LIVEPATCH2' 101 livepatch: '$MOD_LIVEPATCH2': initializing pat 101 livepatch: '$MOD_LIVEPATCH2': initializing patching transition 102 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 102 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 103 $MOD_LIVEPATCH2: allocate_loglevel_state: allo 103 $MOD_LIVEPATCH2: allocate_loglevel_state: allocating space to store console_loglevel 104 livepatch: '$MOD_LIVEPATCH2': starting patchin 104 livepatch: '$MOD_LIVEPATCH2': starting patching transition 105 livepatch: '$MOD_LIVEPATCH2': completing patch 105 livepatch: '$MOD_LIVEPATCH2': completing patching transition 106 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 106 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 107 $MOD_LIVEPATCH2: fix_console_loglevel: fixing 107 $MOD_LIVEPATCH2: fix_console_loglevel: fixing console_loglevel 108 livepatch: '$MOD_LIVEPATCH2': patching complet 108 livepatch: '$MOD_LIVEPATCH2': patching complete 109 % insmod test_modules/$MOD_LIVEPATCH3.ko 109 % insmod test_modules/$MOD_LIVEPATCH3.ko 110 livepatch: enabling patch '$MOD_LIVEPATCH3' 110 livepatch: enabling patch '$MOD_LIVEPATCH3' 111 livepatch: '$MOD_LIVEPATCH3': initializing pat 111 livepatch: '$MOD_LIVEPATCH3': initializing patching transition 112 $MOD_LIVEPATCH3: pre_patch_callback: vmlinux 112 $MOD_LIVEPATCH3: pre_patch_callback: vmlinux 113 $MOD_LIVEPATCH3: allocate_loglevel_state: spac 113 $MOD_LIVEPATCH3: allocate_loglevel_state: space to store console_loglevel already allocated 114 livepatch: '$MOD_LIVEPATCH3': starting patchin 114 livepatch: '$MOD_LIVEPATCH3': starting patching transition 115 livepatch: '$MOD_LIVEPATCH3': completing patch 115 livepatch: '$MOD_LIVEPATCH3': completing patching transition 116 $MOD_LIVEPATCH3: post_patch_callback: vmlinux 116 $MOD_LIVEPATCH3: post_patch_callback: vmlinux 117 $MOD_LIVEPATCH3: fix_console_loglevel: taking 117 $MOD_LIVEPATCH3: fix_console_loglevel: taking over the console_loglevel change 118 livepatch: '$MOD_LIVEPATCH3': patching complet 118 livepatch: '$MOD_LIVEPATCH3': patching complete 119 % rmmod $MOD_LIVEPATCH2 119 % rmmod $MOD_LIVEPATCH2 120 % insmod test_modules/$MOD_LIVEPATCH2.ko 120 % insmod test_modules/$MOD_LIVEPATCH2.ko 121 livepatch: enabling patch '$MOD_LIVEPATCH2' 121 livepatch: enabling patch '$MOD_LIVEPATCH2' 122 livepatch: '$MOD_LIVEPATCH2': initializing pat 122 livepatch: '$MOD_LIVEPATCH2': initializing patching transition 123 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 123 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 124 $MOD_LIVEPATCH2: allocate_loglevel_state: spac 124 $MOD_LIVEPATCH2: allocate_loglevel_state: space to store console_loglevel already allocated 125 livepatch: '$MOD_LIVEPATCH2': starting patchin 125 livepatch: '$MOD_LIVEPATCH2': starting patching transition 126 livepatch: '$MOD_LIVEPATCH2': completing patch 126 livepatch: '$MOD_LIVEPATCH2': completing patching transition 127 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 127 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 128 $MOD_LIVEPATCH2: fix_console_loglevel: taking 128 $MOD_LIVEPATCH2: fix_console_loglevel: taking over the console_loglevel change 129 livepatch: '$MOD_LIVEPATCH2': patching complet 129 livepatch: '$MOD_LIVEPATCH2': patching complete 130 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATC 130 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH2/enabled 131 livepatch: '$MOD_LIVEPATCH2': initializing unp 131 livepatch: '$MOD_LIVEPATCH2': initializing unpatching transition 132 $MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux 132 $MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux 133 $MOD_LIVEPATCH2: restore_console_loglevel: res 133 $MOD_LIVEPATCH2: restore_console_loglevel: restoring console_loglevel 134 livepatch: '$MOD_LIVEPATCH2': starting unpatch 134 livepatch: '$MOD_LIVEPATCH2': starting unpatching transition 135 livepatch: '$MOD_LIVEPATCH2': completing unpat 135 livepatch: '$MOD_LIVEPATCH2': completing unpatching transition 136 $MOD_LIVEPATCH2: post_unpatch_callback: vmlinu 136 $MOD_LIVEPATCH2: post_unpatch_callback: vmlinux 137 $MOD_LIVEPATCH2: free_loglevel_state: freeing 137 $MOD_LIVEPATCH2: free_loglevel_state: freeing space for the stored console_loglevel 138 livepatch: '$MOD_LIVEPATCH2': unpatching compl 138 livepatch: '$MOD_LIVEPATCH2': unpatching complete 139 % rmmod $MOD_LIVEPATCH2 139 % rmmod $MOD_LIVEPATCH2 140 % rmmod $MOD_LIVEPATCH3" 140 % rmmod $MOD_LIVEPATCH3" 141 141 142 142 143 # Failure caused by incompatible cumulative li 143 # Failure caused by incompatible cumulative livepatches 144 144 145 start_test "incompatible cumulative livepatche 145 start_test "incompatible cumulative livepatches" 146 146 147 load_lp $MOD_LIVEPATCH2 147 load_lp $MOD_LIVEPATCH2 148 load_failing_mod $MOD_LIVEPATCH 148 load_failing_mod $MOD_LIVEPATCH 149 disable_lp $MOD_LIVEPATCH2 149 disable_lp $MOD_LIVEPATCH2 150 unload_lp $MOD_LIVEPATCH2 150 unload_lp $MOD_LIVEPATCH2 151 151 152 check_result "% insmod test_modules/$MOD_LIVEP 152 check_result "% insmod test_modules/$MOD_LIVEPATCH2.ko 153 livepatch: enabling patch '$MOD_LIVEPATCH2' 153 livepatch: enabling patch '$MOD_LIVEPATCH2' 154 livepatch: '$MOD_LIVEPATCH2': initializing pat 154 livepatch: '$MOD_LIVEPATCH2': initializing patching transition 155 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 155 $MOD_LIVEPATCH2: pre_patch_callback: vmlinux 156 $MOD_LIVEPATCH2: allocate_loglevel_state: allo 156 $MOD_LIVEPATCH2: allocate_loglevel_state: allocating space to store console_loglevel 157 livepatch: '$MOD_LIVEPATCH2': starting patchin 157 livepatch: '$MOD_LIVEPATCH2': starting patching transition 158 livepatch: '$MOD_LIVEPATCH2': completing patch 158 livepatch: '$MOD_LIVEPATCH2': completing patching transition 159 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 159 $MOD_LIVEPATCH2: post_patch_callback: vmlinux 160 $MOD_LIVEPATCH2: fix_console_loglevel: fixing 160 $MOD_LIVEPATCH2: fix_console_loglevel: fixing console_loglevel 161 livepatch: '$MOD_LIVEPATCH2': patching complet 161 livepatch: '$MOD_LIVEPATCH2': patching complete 162 % insmod test_modules/$MOD_LIVEPATCH.ko 162 % insmod test_modules/$MOD_LIVEPATCH.ko 163 livepatch: Livepatch patch ($MOD_LIVEPATCH) is 163 livepatch: Livepatch patch ($MOD_LIVEPATCH) is not compatible with the already installed livepatches. 164 insmod: ERROR: could not insert module test_mo 164 insmod: ERROR: could not insert module test_modules/$MOD_LIVEPATCH.ko: Invalid parameters 165 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATC 165 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH2/enabled 166 livepatch: '$MOD_LIVEPATCH2': initializing unp 166 livepatch: '$MOD_LIVEPATCH2': initializing unpatching transition 167 $MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux 167 $MOD_LIVEPATCH2: pre_unpatch_callback: vmlinux 168 $MOD_LIVEPATCH2: restore_console_loglevel: res 168 $MOD_LIVEPATCH2: restore_console_loglevel: restoring console_loglevel 169 livepatch: '$MOD_LIVEPATCH2': starting unpatch 169 livepatch: '$MOD_LIVEPATCH2': starting unpatching transition 170 livepatch: '$MOD_LIVEPATCH2': completing unpat 170 livepatch: '$MOD_LIVEPATCH2': completing unpatching transition 171 $MOD_LIVEPATCH2: post_unpatch_callback: vmlinu 171 $MOD_LIVEPATCH2: post_unpatch_callback: vmlinux 172 $MOD_LIVEPATCH2: free_loglevel_state: freeing 172 $MOD_LIVEPATCH2: free_loglevel_state: freeing space for the stored console_loglevel 173 livepatch: '$MOD_LIVEPATCH2': unpatching compl 173 livepatch: '$MOD_LIVEPATCH2': unpatching complete 174 % rmmod $MOD_LIVEPATCH2" 174 % rmmod $MOD_LIVEPATCH2" 175 175 176 exit 0 176 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.