linux/kernel/livepatch
Chengming Zhou 2957308343 livepatch: Don't block removal of patches that are safe to unload
module_put() is not called for a patch with "forced" flag. It should
block the removal of the livepatch module when the code might still
be in use after forced transition.

klp_force_transition() currently sets "forced" flag for all patches on
the list.

In fact, any patch can be safely unloaded when it passed through
the consistency model in KLP_UNPATCHED transition.

In other words, the "forced" flag must be set only for livepatches
that are being removed. In particular, set the "forced" flag:

  + only for klp_transition_patch when the transition to KLP_UNPATCHED
    state was forced.

  + all replaced patches when the transition to KLP_PATCHED state was
    forced and the patch was replacing the existing patches.

Signed-off-by: Chengming Zhou <zhouchengming@bytedance.com>
Acked-by: Joe Lawrence <joe.lawrence@redhat.com>
Reviewed-by: Petr Mladek <pmladek@suse.com>
Tested-by: Petr Mladek <pmladek@suse.com>
[mbenes@suse.cz: wording improvements]
Signed-off-by: Petr Mladek <pmladek@suse.com>
Link: https://lore.kernel.org/r/20220312152220.88127-1-zhouchengming@bytedance.com
2022-03-17 19:02:30 +01:00
..
core.c livepatch: Fix missing unlock on error in klp_enable_patch() 2022-01-04 13:57:19 +01:00
core.h livepatch: Keep replaced patches until post_patch callback is called 2019-11-01 13:08:08 +01:00
Kconfig livepatch: Use the default ftrace_ops instead of REGS when ARGS is available 2020-11-13 12:15:28 -05:00
Makefile livepatch: Basic API to track system state changes 2019-11-01 13:08:14 +01:00
patch.c ftrace: disable preemption when recursion locked 2021-10-27 11:21:49 -04:00
patch.h livepatch: Remove Nop structures when unused 2019-01-11 20:51:24 +01:00
shadow.c Documentation: livepatch: Add livepatch API page 2021-12-23 11:35:53 +01:00
state.c kernel/: fix repeated words in comments 2020-10-16 11:11:19 -07:00
state.h livepatch: Allow to distinguish different version of system state changes 2019-11-01 13:08:19 +01:00
transition.c livepatch: Don't block removal of patches that are safe to unload 2022-03-17 19:02:30 +01:00
transition.h livepatch: Remove signal sysfs attribute 2019-01-16 22:09:33 +01:00