diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-10-10 11:36:19 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-10-10 11:36:19 -0700 |
| commit | 4de65c5830233e7a4adf2e679510089ec4e210c7 (patch) | |
| tree | 1b43fc3da753b18242bbad08c68ef65fa0a1a2a9 /kernel/livepatch/transition.c | |
| parent | Merge tag 'printk-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/p... (diff) | |
| parent | Merge branch 'for-6.1/sysfs-patched-object' into for-linus (diff) | |
| download | linux-4de65c5830233e7a4adf2e679510089ec4e210c7.tar.gz linux-4de65c5830233e7a4adf2e679510089ec4e210c7.zip | |
Merge tag 'livepatching-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
Pull livepatching updates from Petr Mladek:
- Fix race between fork and livepatch transition revert
- Add sysfs entry that shows "patched" state for each object (module)
that can be livepatched by the given livepatch
- Some clean up
* tag 'livepatching-for-6.1' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching:
selftests/livepatch: add sysfs test
livepatch: add sysfs entry "patched" for each klp_object
selftests/livepatch: normalize sysctl error message
livepatch: Add a missing newline character in klp_module_coming()
livepatch: fix race between fork and KLP transition
Diffstat (limited to 'kernel/livepatch/transition.c')
| -rw-r--r-- | kernel/livepatch/transition.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index 5d03a2ad1066..30187b1d8275 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -610,9 +610,23 @@ void klp_reverse_transition(void) /* Called from copy_process() during fork */ void klp_copy_process(struct task_struct *child) { - child->patch_state = current->patch_state; - /* TIF_PATCH_PENDING gets copied in setup_thread_stack() */ + /* + * The parent process may have gone through a KLP transition since + * the thread flag was copied in setup_thread_stack earlier. Bring + * the task flag up to date with the parent here. + * + * The operation is serialized against all klp_*_transition() + * operations by the tasklist_lock. The only exception is + * klp_update_patch_state(current), but we cannot race with + * that because we are current. + */ + if (test_tsk_thread_flag(current, TIF_PATCH_PENDING)) + set_tsk_thread_flag(child, TIF_PATCH_PENDING); + else + clear_tsk_thread_flag(child, TIF_PATCH_PENDING); + + child->patch_state = current->patch_state; } /* |
