Lines Matching +full:target +full:- +full:module

2 # SPDX-License-Identifier: GPL-2.0
15 # Test a combination of loading a kernel module and a livepatch that
16 # patches a function in the first module. Load the target module
17 # before the livepatch module. Unload them in the same order.
19 # - On livepatch enable, before the livepatch transition starts,
20 # pre-patch callbacks are executed for vmlinux and $MOD_TARGET (those
22 # according to the klp_patch, their post-patch callbacks run and the
25 # - Similarly, on livepatch disable, pre-patch callbacks run before the
26 # unpatching transition starts. klp_objects are reverted, post-patch
29 start_test "target module before livepatch"
43 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
47 $MOD_LIVEPATCH: post_patch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
52 $MOD_LIVEPATCH: pre_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
56 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
64 # module before the target kernel module. This tests the livepatch
67 # - On livepatch enable, only pre/post-patch callbacks are executed for
70 # - When a targeted module is subsequently loaded, only its
71 # pre/post-patch callbacks are executed.
73 # - On livepatch disable, all currently loaded klp_objects' (vmlinux and
74 # $MOD_TARGET) pre/post-unpatch callbacks are executed.
93 livepatch: applying patch '$MOD_LIVEPATCH' to loading module '$MOD_TARGET'
94 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modul…
95 $MOD_LIVEPATCH: post_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modu…
100 $MOD_LIVEPATCH: pre_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
104 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
111 # Test loading the livepatch after a targeted kernel module, then unload
112 # the kernel module before disabling the livepatch. This tests the
115 # - First load a target module, then the livepatch.
117 # - When a target module is unloaded, the livepatch is only reverted
119 # post-unpatch callbacks are executed when this occurs.
121 # - When the livepatch is disabled, pre and post-unpatch callbacks are
138 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
142 $MOD_LIVEPATCH: post_patch_callback: $MOD_TARGET -> [MODULE_STATE_LIVE] Normal state
146 $MOD_LIVEPATCH: pre_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_GOING] Going away
147 livepatch: reverting patch '$MOD_LIVEPATCH' on unloading module '$MOD_TARGET'
148 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_GOING] Going away
163 # - First load the livepatch.
165 # - When a targeted kernel module is subsequently loaded, only its
166 # pre/post-patch callbacks are executed.
168 # - When the target module is unloaded, the livepatch is only reverted
170 # post-unpatch callbacks are executed when this occurs.
189 livepatch: applying patch '$MOD_LIVEPATCH' to loading module '$MOD_TARGET'
190 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modul…
191 $MOD_LIVEPATCH: post_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modu…
195 $MOD_LIVEPATCH: pre_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_GOING] Going away
196 livepatch: reverting patch '$MOD_LIVEPATCH' on unloading module '$MOD_TARGET'
197 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_GOING] Going away
208 # A simple test of loading a livepatch without one of its patch target
211 # - Load the livepatch.
213 # - As expected, only pre/post-(un)patch handlers are executed for
216 start_test "target module not present"
240 # Test a scenario where a vmlinux pre-patch callback returns a non-zero
243 # - First load a target module.
245 # - Load the livepatch module, setting its 'pre_patch_ret' value to -19
246 # (-ENODEV). When its vmlinux pre-patch callback executes, this
247 # status code will propagate back to the module-loading subsystem.
249 # module.
251 start_test "pre-patch callback -ENODEV"
254 load_failing_mod $MOD_LIVEPATCH pre_patch_ret=-19
259 % modprobe $MOD_LIVEPATCH pre_patch_ret=-19
263 livepatch: pre-patch callback failed for object 'vmlinux'
274 # pre-patch callback returns success. However, when a targeted kernel
275 # module is later loaded, have the livepatch return a failing status
278 # - Load the livepatch, vmlinux pre-patch callback succeeds.
280 # - Set a trap so subsequent pre-patch callbacks to this livepatch will
281 # return -ENODEV.
283 # - The livepatch pre-patch callback for subsequently loaded target
284 # modules will return failure, so the module loader refuses to load
285 # the kernel module. No post-patch or pre/post-unpatch callbacks are
288 # - Pre/post-unpatch callbacks are run for the vmlinux klp_object.
290 start_test "module_coming + pre-patch callback -ENODEV"
293 set_pre_patch_ret $MOD_LIVEPATCH -19
306 % echo -19 > /sys/module/$MOD_LIVEPATCH/parameters/pre_patch_ret
308 livepatch: applying patch '$MOD_LIVEPATCH' to loading module '$MOD_TARGET'
309 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modul…
310 livepatch: pre-patch callback failed for object '$MOD_TARGET'
311 livepatch: patch '$MOD_LIVEPATCH' failed for module '$MOD_TARGET', refusing to load module '$MOD_TA…
323 # Test loading multiple targeted kernel modules. This test-case is
324 # mainly for comparing with the next test-case.
326 # - Load a target "busy" kernel module which kicks off a worker function
329 # - Proceed with loading the livepatch and another ordinary target
330 # module. Post-patch callbacks are executed and the transition
333 start_test "multiple target modules"
351 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET_BUSY -> [MODULE_STATE_LIVE] Normal state
355 $MOD_LIVEPATCH: post_patch_callback: $MOD_TARGET_BUSY -> [MODULE_STATE_LIVE] Normal state
358 livepatch: applying patch '$MOD_LIVEPATCH' to loading module '$MOD_TARGET'
359 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modul…
360 $MOD_LIVEPATCH: post_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modu…
364 $MOD_LIVEPATCH: pre_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_GOING] Going away
365 livepatch: reverting patch '$MOD_LIVEPATCH' on unloading module '$MOD_TARGET'
366 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_GOING] Going away
370 $MOD_LIVEPATCH: pre_unpatch_callback: $MOD_TARGET_BUSY -> [MODULE_STATE_LIVE] Normal state
374 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET_BUSY -> [MODULE_STATE_LIVE] Normal state
381 # A similar test as the previous one, but force the "busy" kernel module
385 # executing a to-be-patched function -- the consistency model stalls the
386 # current patch transition until this safety-check is met. Test a
387 # scenario where one of a livepatch's target klp_objects sits on such a
388 # function for a long time. Meanwhile, load and unload other target
391 # - Load the "busy" kernel module, this time make its work function loop
393 # - Meanwhile, the livepatch is loaded. Notice that the patch
394 # transition does not complete as the targeted "busy" module is
395 # sitting on a to-be-patched function.
397 # - Load a second target module (this one is an ordinary idle kernel
398 # module). Note that *no* post-patch callbacks will be executed while
401 # - Request an unload of the simple kernel module. The patch is still
402 # transitioning, so its pre-unpatch callbacks are skipped.
404 # - Finally the livepatch is disabled. Since none of the patch's
405 # klp_object's post-patch callbacks executed, the remaining
406 # klp_object's pre-unpatch callbacks are skipped.
408 start_test "busy target module"
413 # Wait until the livepatch reports in-transition state, i.e. that it's
415 loop_until 'grep -q '^1$' /sys/kernel/livepatch/$MOD_LIVEPATCH/transition' ||
431 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET_BUSY -> [MODULE_STATE_LIVE] Normal state
434 livepatch: applying patch '$MOD_LIVEPATCH' to loading module '$MOD_TARGET'
435 $MOD_LIVEPATCH: pre_patch_callback: $MOD_TARGET -> [MODULE_STATE_COMING] Full formed, running modul…
439 livepatch: reverting patch '$MOD_LIVEPATCH' on unloading module '$MOD_TARGET'
440 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET -> [MODULE_STATE_GOING] Going away
446 $MOD_LIVEPATCH: post_unpatch_callback: $MOD_TARGET_BUSY -> [MODULE_STATE_LIVE] Normal state
454 # Test loading multiple livepatches. This test-case is mainly for comparing
455 # with the next test-case.
457 # - Load and unload two livepatches, pre and post (un)patch callbacks
504 # Load multiple livepatches, but the second as an 'atomic-replace'
506 # disabled and *none* of its pre/post-unpatch callbacks executed. On
507 # the other hand, when the atomic-replace livepatch is disabled, its
508 # pre/post-unpatch callbacks *should* be executed.
510 # - Load and unload two livepatches, the second of which has its
513 # - Pre and post patch callbacks are executed for both livepatches.
515 # - Once the atomic replace module is loaded, only its pre and post