~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/livepatch/test-state.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php