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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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 ] ~

Diff markup

Differences between /tools/testing/selftests/livepatch/test-livepatch.sh (Version linux-6.11-rc3) and /tools/testing/selftests/livepatch/test-livepatch.sh (Version linux-5.8.18)


  1 #!/bin/bash                                         1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0                  2 # SPDX-License-Identifier: GPL-2.0
  3 # Copyright (C) 2018 Joe Lawrence <joe.lawrence      3 # Copyright (C) 2018 Joe Lawrence <joe.lawrence@redhat.com>
  4                                                     4 
  5 . $(dirname $0)/functions.sh                        5 . $(dirname $0)/functions.sh
  6                                                     6 
  7 MOD_LIVEPATCH1=test_klp_livepatch              !!   7 MOD_LIVEPATCH=test_klp_livepatch
  8 MOD_LIVEPATCH2=test_klp_syscall                << 
  9 MOD_LIVEPATCH3=test_klp_callbacks_demo         << 
 10 MOD_REPLACE=test_klp_atomic_replace                 8 MOD_REPLACE=test_klp_atomic_replace
 11                                                     9 
 12 setup_config                                       10 setup_config
 13                                                    11 
 14                                                    12 
                                                   >>  13 # TEST: basic function patching
 15 # - load a livepatch that modifies the output      14 # - load a livepatch that modifies the output from /proc/cmdline and
 16 #   verify correct behavior                        15 #   verify correct behavior
 17 # - unload the livepatch and make sure the pat     16 # - unload the livepatch and make sure the patch was removed
 18                                                    17 
 19 start_test "basic function patching"           !!  18 echo -n "TEST: basic function patching ... "
                                                   >>  19 dmesg -C
 20                                                    20 
 21 load_lp $MOD_LIVEPATCH1                        !!  21 load_lp $MOD_LIVEPATCH
 22                                                    22 
 23 if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATC !!  23 if [[ "$(cat /proc/cmdline)" != "$MOD_LIVEPATCH: this has been live patched" ]] ; then
 24         echo -e "FAIL\n\n"                         24         echo -e "FAIL\n\n"
 25         die "livepatch kselftest(s) failed"        25         die "livepatch kselftest(s) failed"
 26 fi                                                 26 fi
 27                                                    27 
 28 disable_lp $MOD_LIVEPATCH1                     !!  28 disable_lp $MOD_LIVEPATCH
 29 unload_lp $MOD_LIVEPATCH1                      !!  29 unload_lp $MOD_LIVEPATCH
 30                                                    30 
 31 if [[ "$(cat /proc/cmdline)" == "$MOD_LIVEPATC !!  31 if [[ "$(cat /proc/cmdline)" == "$MOD_LIVEPATCH: this has been live patched" ]] ; then
 32         echo -e "FAIL\n\n"                         32         echo -e "FAIL\n\n"
 33         die "livepatch kselftest(s) failed"        33         die "livepatch kselftest(s) failed"
 34 fi                                                 34 fi
 35                                                    35 
 36 check_result "% insmod test_modules/$MOD_LIVEP !!  36 check_result "% modprobe $MOD_LIVEPATCH
 37 livepatch: enabling patch '$MOD_LIVEPATCH1'    !!  37 livepatch: enabling patch '$MOD_LIVEPATCH'
 38 livepatch: '$MOD_LIVEPATCH1': initializing pat !!  38 livepatch: '$MOD_LIVEPATCH': initializing patching transition
 39 livepatch: '$MOD_LIVEPATCH1': starting patchin !!  39 livepatch: '$MOD_LIVEPATCH': starting patching transition
 40 livepatch: '$MOD_LIVEPATCH1': completing patch !!  40 livepatch: '$MOD_LIVEPATCH': completing patching transition
 41 livepatch: '$MOD_LIVEPATCH1': patching complet !!  41 livepatch: '$MOD_LIVEPATCH': patching complete
 42 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATC !!  42 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled
 43 livepatch: '$MOD_LIVEPATCH1': initializing unp !!  43 livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
 44 livepatch: '$MOD_LIVEPATCH1': starting unpatch !!  44 livepatch: '$MOD_LIVEPATCH': starting unpatching transition
 45 livepatch: '$MOD_LIVEPATCH1': completing unpat !!  45 livepatch: '$MOD_LIVEPATCH': completing unpatching transition
 46 livepatch: '$MOD_LIVEPATCH1': unpatching compl !!  46 livepatch: '$MOD_LIVEPATCH': unpatching complete
 47 % rmmod $MOD_LIVEPATCH1"                       !!  47 % rmmod $MOD_LIVEPATCH"
 48                                                    48 
 49                                                    49 
                                                   >>  50 # TEST: multiple livepatches
 50 # - load a livepatch that modifies the output      51 # - load a livepatch that modifies the output from /proc/cmdline and
 51 #   verify correct behavior                        52 #   verify correct behavior
 52 # - load another livepatch and verify that bot     53 # - load another livepatch and verify that both livepatches are active
 53 # - unload the second livepatch and verify tha     54 # - unload the second livepatch and verify that the first is still active
 54 # - unload the first livepatch and verify none     55 # - unload the first livepatch and verify none are active
 55                                                    56 
 56 start_test "multiple livepatches"              !!  57 echo -n "TEST: multiple livepatches ... "
                                                   >>  58 dmesg -C
 57                                                    59 
 58 load_lp $MOD_LIVEPATCH1                        !!  60 load_lp $MOD_LIVEPATCH
 59                                                    61 
 60 grep 'live patched' /proc/cmdline > /dev/kmsg      62 grep 'live patched' /proc/cmdline > /dev/kmsg
 61 grep 'live patched' /proc/meminfo > /dev/kmsg      63 grep 'live patched' /proc/meminfo > /dev/kmsg
 62                                                    64 
 63 load_lp $MOD_REPLACE replace=0                     65 load_lp $MOD_REPLACE replace=0
 64                                                    66 
 65 grep 'live patched' /proc/cmdline > /dev/kmsg      67 grep 'live patched' /proc/cmdline > /dev/kmsg
 66 grep 'live patched' /proc/meminfo > /dev/kmsg      68 grep 'live patched' /proc/meminfo > /dev/kmsg
 67                                                    69 
 68 disable_lp $MOD_REPLACE                            70 disable_lp $MOD_REPLACE
 69 unload_lp $MOD_REPLACE                             71 unload_lp $MOD_REPLACE
 70                                                    72 
 71 grep 'live patched' /proc/cmdline > /dev/kmsg      73 grep 'live patched' /proc/cmdline > /dev/kmsg
 72 grep 'live patched' /proc/meminfo > /dev/kmsg      74 grep 'live patched' /proc/meminfo > /dev/kmsg
 73                                                    75 
 74 disable_lp $MOD_LIVEPATCH1                     !!  76 disable_lp $MOD_LIVEPATCH
 75 unload_lp $MOD_LIVEPATCH1                      !!  77 unload_lp $MOD_LIVEPATCH
 76                                                    78 
 77 grep 'live patched' /proc/cmdline > /dev/kmsg      79 grep 'live patched' /proc/cmdline > /dev/kmsg
 78 grep 'live patched' /proc/meminfo > /dev/kmsg      80 grep 'live patched' /proc/meminfo > /dev/kmsg
 79                                                    81 
 80 check_result "% insmod test_modules/$MOD_LIVEP !!  82 check_result "% modprobe $MOD_LIVEPATCH
 81 livepatch: enabling patch '$MOD_LIVEPATCH1'    !!  83 livepatch: enabling patch '$MOD_LIVEPATCH'
 82 livepatch: '$MOD_LIVEPATCH1': initializing pat !!  84 livepatch: '$MOD_LIVEPATCH': initializing patching transition
 83 livepatch: '$MOD_LIVEPATCH1': starting patchin !!  85 livepatch: '$MOD_LIVEPATCH': starting patching transition
 84 livepatch: '$MOD_LIVEPATCH1': completing patch !!  86 livepatch: '$MOD_LIVEPATCH': completing patching transition
 85 livepatch: '$MOD_LIVEPATCH1': patching complet !!  87 livepatch: '$MOD_LIVEPATCH': patching complete
 86 $MOD_LIVEPATCH1: this has been live patched    !!  88 $MOD_LIVEPATCH: this has been live patched
 87 % insmod test_modules/$MOD_REPLACE.ko replace= !!  89 % modprobe $MOD_REPLACE replace=0
 88 livepatch: enabling patch '$MOD_REPLACE'           90 livepatch: enabling patch '$MOD_REPLACE'
 89 livepatch: '$MOD_REPLACE': initializing patchi     91 livepatch: '$MOD_REPLACE': initializing patching transition
 90 livepatch: '$MOD_REPLACE': starting patching t     92 livepatch: '$MOD_REPLACE': starting patching transition
 91 livepatch: '$MOD_REPLACE': completing patching     93 livepatch: '$MOD_REPLACE': completing patching transition
 92 livepatch: '$MOD_REPLACE': patching complete       94 livepatch: '$MOD_REPLACE': patching complete
 93 $MOD_LIVEPATCH1: this has been live patched    !!  95 $MOD_LIVEPATCH: this has been live patched
 94 $MOD_REPLACE: this has been live patched           96 $MOD_REPLACE: this has been live patched
 95 % echo 0 > /sys/kernel/livepatch/$MOD_REPLACE/     97 % echo 0 > /sys/kernel/livepatch/$MOD_REPLACE/enabled
 96 livepatch: '$MOD_REPLACE': initializing unpatc     98 livepatch: '$MOD_REPLACE': initializing unpatching transition
 97 livepatch: '$MOD_REPLACE': starting unpatching     99 livepatch: '$MOD_REPLACE': starting unpatching transition
 98 livepatch: '$MOD_REPLACE': completing unpatchi    100 livepatch: '$MOD_REPLACE': completing unpatching transition
 99 livepatch: '$MOD_REPLACE': unpatching complete    101 livepatch: '$MOD_REPLACE': unpatching complete
100 % rmmod $MOD_REPLACE                              102 % rmmod $MOD_REPLACE
101 $MOD_LIVEPATCH1: this has been live patched    !! 103 $MOD_LIVEPATCH: this has been live patched
102 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATC !! 104 % echo 0 > /sys/kernel/livepatch/$MOD_LIVEPATCH/enabled
103 livepatch: '$MOD_LIVEPATCH1': initializing unp !! 105 livepatch: '$MOD_LIVEPATCH': initializing unpatching transition
104 livepatch: '$MOD_LIVEPATCH1': starting unpatch !! 106 livepatch: '$MOD_LIVEPATCH': starting unpatching transition
105 livepatch: '$MOD_LIVEPATCH1': completing unpat !! 107 livepatch: '$MOD_LIVEPATCH': completing unpatching transition
106 livepatch: '$MOD_LIVEPATCH1': unpatching compl !! 108 livepatch: '$MOD_LIVEPATCH': unpatching complete
107 % rmmod $MOD_LIVEPATCH1"                       !! 109 % rmmod $MOD_LIVEPATCH"
108                                                   110 
109                                                   111 
                                                   >> 112 # TEST: atomic replace livepatch
110 # - load a livepatch that modifies the output     113 # - load a livepatch that modifies the output from /proc/cmdline and
111 #   verify correct behavior                       114 #   verify correct behavior
112 # - load two additional livepatches and check  !! 115 # - load an atomic replace livepatch and verify that only the second is active
113 #   applied                                    !! 116 # - remove the first livepatch and verify that the atomic replace livepatch
114 # - load an atomic replace livepatch and check !! 117 #   is still active
115 #   disabled                                   << 
116 # - remove all livepatches besides the atomic  << 
117 #   atomic replace livepatch is still active   << 
118 # - remove the atomic replace livepatch and ve    118 # - remove the atomic replace livepatch and verify that none are active
119                                                   119 
120 start_test "atomic replace livepatch"          !! 120 echo -n "TEST: atomic replace livepatch ... "
                                                   >> 121 dmesg -C
121                                                   122 
122 load_lp $MOD_LIVEPATCH1                        !! 123 load_lp $MOD_LIVEPATCH
123                                                   124 
124 grep 'live patched' /proc/cmdline > /dev/kmsg     125 grep 'live patched' /proc/cmdline > /dev/kmsg
125 grep 'live patched' /proc/meminfo > /dev/kmsg     126 grep 'live patched' /proc/meminfo > /dev/kmsg
126                                                   127 
127 for mod in $MOD_LIVEPATCH2 $MOD_LIVEPATCH3; do << 
128         load_lp "$mod"                         << 
129 done                                           << 
130                                                << 
131 mods=(/sys/kernel/livepatch/*)                 << 
132 nmods=${#mods[@]}                              << 
133 if [ "$nmods" -ne 3 ]; then                    << 
134         die "Expecting three modules listed, f << 
135 fi                                             << 
136                                                << 
137 load_lp $MOD_REPLACE replace=1                    128 load_lp $MOD_REPLACE replace=1
138                                                   129 
139 grep 'live patched' /proc/cmdline > /dev/kmsg     130 grep 'live patched' /proc/cmdline > /dev/kmsg
140 grep 'live patched' /proc/meminfo > /dev/kmsg     131 grep 'live patched' /proc/meminfo > /dev/kmsg
141                                                   132 
142 mods=(/sys/kernel/livepatch/*)                 !! 133 unload_lp $MOD_LIVEPATCH
143 nmods=${#mods[@]}                              << 
144 if [ "$nmods" -ne 1 ]; then                    << 
145         die "Expecting only one moduled listed << 
146 fi                                             << 
147                                                << 
148 # These modules were disabled by the atomic re << 
149 for mod in $MOD_LIVEPATCH3 $MOD_LIVEPATCH2 $MO << 
150         unload_lp "$mod"                       << 
151 done                                           << 
152                                                   134 
153 grep 'live patched' /proc/cmdline > /dev/kmsg     135 grep 'live patched' /proc/cmdline > /dev/kmsg
154 grep 'live patched' /proc/meminfo > /dev/kmsg     136 grep 'live patched' /proc/meminfo > /dev/kmsg
155                                                   137 
156 disable_lp $MOD_REPLACE                           138 disable_lp $MOD_REPLACE
157 unload_lp $MOD_REPLACE                            139 unload_lp $MOD_REPLACE
158                                                   140 
159 grep 'live patched' /proc/cmdline > /dev/kmsg     141 grep 'live patched' /proc/cmdline > /dev/kmsg
160 grep 'live patched' /proc/meminfo > /dev/kmsg     142 grep 'live patched' /proc/meminfo > /dev/kmsg
161                                                   143 
162 check_result "% insmod test_modules/$MOD_LIVEP !! 144 check_result "% modprobe $MOD_LIVEPATCH
163 livepatch: enabling patch '$MOD_LIVEPATCH1'    !! 145 livepatch: enabling patch '$MOD_LIVEPATCH'
164 livepatch: '$MOD_LIVEPATCH1': initializing pat !! 146 livepatch: '$MOD_LIVEPATCH': initializing patching transition
165 livepatch: '$MOD_LIVEPATCH1': starting patchin !! 147 livepatch: '$MOD_LIVEPATCH': starting patching transition
166 livepatch: '$MOD_LIVEPATCH1': completing patch !! 148 livepatch: '$MOD_LIVEPATCH': completing patching transition
167 livepatch: '$MOD_LIVEPATCH1': patching complet !! 149 livepatch: '$MOD_LIVEPATCH': patching complete
168 $MOD_LIVEPATCH1: this has been live patched    !! 150 $MOD_LIVEPATCH: this has been live patched
169 % insmod test_modules/$MOD_LIVEPATCH2.ko       !! 151 % modprobe $MOD_REPLACE replace=1
170 livepatch: enabling patch '$MOD_LIVEPATCH2'    << 
171 livepatch: '$MOD_LIVEPATCH2': initializing pat << 
172 livepatch: '$MOD_LIVEPATCH2': starting patchin << 
173 livepatch: '$MOD_LIVEPATCH2': completing patch << 
174 livepatch: '$MOD_LIVEPATCH2': patching complet << 
175 % insmod test_modules/$MOD_LIVEPATCH3.ko       << 
176 livepatch: enabling patch '$MOD_LIVEPATCH3'    << 
177 livepatch: '$MOD_LIVEPATCH3': initializing pat << 
178 $MOD_LIVEPATCH3: pre_patch_callback: vmlinux   << 
179 livepatch: '$MOD_LIVEPATCH3': starting patchin << 
180 livepatch: '$MOD_LIVEPATCH3': completing patch << 
181 $MOD_LIVEPATCH3: post_patch_callback: vmlinux  << 
182 livepatch: '$MOD_LIVEPATCH3': patching complet << 
183 % insmod test_modules/$MOD_REPLACE.ko replace= << 
184 livepatch: enabling patch '$MOD_REPLACE'          152 livepatch: enabling patch '$MOD_REPLACE'
185 livepatch: '$MOD_REPLACE': initializing patchi    153 livepatch: '$MOD_REPLACE': initializing patching transition
186 livepatch: '$MOD_REPLACE': starting patching t    154 livepatch: '$MOD_REPLACE': starting patching transition
187 livepatch: '$MOD_REPLACE': completing patching    155 livepatch: '$MOD_REPLACE': completing patching transition
188 livepatch: '$MOD_REPLACE': patching complete      156 livepatch: '$MOD_REPLACE': patching complete
189 $MOD_REPLACE: this has been live patched          157 $MOD_REPLACE: this has been live patched
190 % rmmod $MOD_LIVEPATCH3                        !! 158 % rmmod $MOD_LIVEPATCH
191 % rmmod $MOD_LIVEPATCH2                        << 
192 % rmmod $MOD_LIVEPATCH1                        << 
193 $MOD_REPLACE: this has been live patched          159 $MOD_REPLACE: this has been live patched
194 % echo 0 > /sys/kernel/livepatch/$MOD_REPLACE/    160 % echo 0 > /sys/kernel/livepatch/$MOD_REPLACE/enabled
195 livepatch: '$MOD_REPLACE': initializing unpatc    161 livepatch: '$MOD_REPLACE': initializing unpatching transition
196 livepatch: '$MOD_REPLACE': starting unpatching    162 livepatch: '$MOD_REPLACE': starting unpatching transition
197 livepatch: '$MOD_REPLACE': completing unpatchi    163 livepatch: '$MOD_REPLACE': completing unpatching transition
198 livepatch: '$MOD_REPLACE': unpatching complete    164 livepatch: '$MOD_REPLACE': unpatching complete
199 % rmmod $MOD_REPLACE"                             165 % rmmod $MOD_REPLACE"
200                                                   166 
201                                                   167 
202 exit 0                                            168 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