Skip to content

livepatch: hybrid consistency model

Josh Poimboeuf linux-s390 linuxppc-dev lkml 5 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest15 patches 24 repliesIn review
  2. v415 patches 27 repliesSuperseded
  3. v315 patches 62 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v2 RFC18 patches99 repliesSuperseded
v1 RFC14 patches70 repliesSuperseded

Changes in v5 from the cover letter

- return -EINVAL in __save_stack_trace_reliable()
- only call show_stack() once
- add save_stack_trace_tsk_reliable() define for !CONFIG_STACKTRACE
- update kernel version and date in ABI doc
- make suggested improvements to livepatch.txt
- update barrier comments
- remove klp_try_complete_transition() call from klp_start_transition()
- move end of klp_try_complete_transition() into klp_complete_transition()
- fix __klp_enable_patch() error path
- check for transition in klp_module_going()

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/15stacktrace/x86: add function for detecting reliable stack tracesarch/Kconfig arch/x86/Kconfig arch/x86/include/asm/unwind.h +4 more+126 -66 replies
2/15x86/entry: define _TIF_ALLWORK_MASK flags explicitlyarch/x86/include/asm/thread_info.h+5 -60 replies
3/15livepatch: create temporary klp_update_patch_state() stubinclude/linux/livepatch.h kernel/livepatch/core.c+7 -10 replies
4/15livepatch/x86: add TIF_PATCH_PENDING thread flagarch/x86/entry/common.c arch/x86/include/asm/thread_info.h+9 -40 replies
5/15livepatch/powerpc: add TIF_PATCH_PENDING thread flagarch/powerpc/include/asm/thread_info.h arch/powerpc/kernel/signal.c+7 -12 replies
6/15livepatch/s390: reorganize TIF thread flag bitsarch/s390/include/asm/thread_info.h+14 -80 replies
7/15livepatch/s390: add TIF_PATCH_PENDING thread flagarch/s390/include/asm/thread_info.h arch/s390/kernel/entry.S+32 -10 replies
8/15livepatch: separate enabled and patched statesinclude/linux/livepatch.h kernel/livepatch/core.c+42 -470 replies
9/15livepatch: remove unnecessary object loaded checkkernel/livepatch/core.c+0 -30 replies
10/15livepatch: move patching functions into patch.ckernel/livepatch/Makefile kernel/livepatch/core.c kernel/livepatch/patch.c +1 more+247 -2020 replies
11/15livepatch: use kstrtobool() in enabled_store()kernel/livepatch/core.c+5 -80 replies
12/15livepatch: store function sizesinclude/linux/livepatch.h kernel/livepatch/core.c+19 -00 replies
13/15livepatch: change to a per-task consistency modelDocumentation/ABI/testing/sysfs-kernel-livepatch Documentation/livepatch/livepatch.txt include/linux/init_task.h +11 more+947 -4912 replies
14/15livepatch: add /proc/<pid>/patch_stateDocumentation/filesystems/proc.txt fs/proc/base.c+33 -00 replies
15/15livepatch: allow removal of a disabled patchDocumentation/livepatch/livepatch.txt include/linux/livepatch.h kernel/livepatch/core.c +2 more+72 -520 replies
15/15livepatch: allow removal of a disabled patchDocumentation/livepatch/livepatch.txt include/linux/livepatch.h kernel/livepatch/core.c +2 more+96 -531 reply

Reviews trailers per patch

15 of 16 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchPetr MladekMiroslav BenesKamalesh BabulalAndy LutomirskiBalbir SinghIngo MolnarMichael Ellerman
SeriesA-b
1/15R-b R-b
2/15R-b R-b R-b
3/15R-b
4/15R-b R-b R-b A-b
5/15R-b R-b R-b R-b A-b
6/15R-b
7/15
8/15R-b A-b R-b
9/15R-b A-b R-b
10/15R-b A-b R-b
11/15R-b A-b
12/15R-b A-b R-b
13/15R-b A-b
14/15R-b R-b
15/15R-b R-b A-b
15/15R-b R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v5 thread

Cover letter [PATCH v5 00/15] livepatch: hybrid consistency model

Here's v5 of the consistency model, targeted for 4.12. Only a few minor changes this time.

I would very much appreciate reviews/acks from the following:

- Michael Ellerman for the powerpc changes in patch 5.

- Heiko Carstens for the s390 changes in patches 6 & 7.

- Peter Zijlstra/Ingo Molnar for the use of task_rq_lock() and the modification of do_idle() in patch 13.

Thanks!

Based on linux-next/master (20170213).

v5:
- return -EINVAL in __save_stack_trace_reliable()
- only call show_stack() once
- add save_stack_trace_tsk_reliable() define for !CONFIG_STACKTRACE
- update kernel version and date in ABI doc
- make suggested improvements to livepatch.txt
- update barrier comments
- remove klp_try_complete_transition() call from klp_start_transition()
- move end of klp_try_complete_transition() into klp_complete_transition()
- fix __klp_enable_patch() error path
- check for transition in klp_module_going()

v4:
- add warnings for "impossible" scenarios in __save_stack_trace_reliable()
- sort _TIF_ALLWORK_MASK flags
- move klp_transition_work to transition.c. This resulted in the following related changes:
- klp_mutex is now visible to transition.c
- klp_start_transition() now calls klp_try_complete_transition()
- klp_try_complete_transition() now sets up the work
- rearrange code in transition.c accordingly
- klp_reverse_transition(): clear TIF flags and call synchronize_rcu()
- klp_try_complete_transition(): do synchronize_rcu() only when unpatching
- klp_start_transition(): only set TIF flags when necessary
- klp_complete_transition(): add synchronize_rcu() when patching
- klp_ftrace_handler(): put WARN_ON_ONCE back in and add comment
- use for_each_possible_cpu() to patch offline idle tasks
- add warnings to sample module when setting patch.immediate
- don't use pr_debug() with the task rq lock
- add documentation about porting consistency model to other arches
- move klp_patch_pending() to patch 13
- improve several comments and commit messages

v3:
- rebase on new x86 unwinder
- force !HAVE_RELIABLE_STACKTRACE arches to use patch->immediate for now, because we don't have a way to transition kthreads otherwise
- rebase s390 TIF_PATCH_PENDING patch onto latest entry code
- update barrier comments and move barrier from the end of klp_init_transition() to its callers
- "klp_work" -> "klp_transition_work"
- "klp_patch_task()" -> "klp_update_patch_state()"
- explicit _TIF_ALLWORK_MASK
- change klp_reverse_transition() to not try to complete transition. instead modify the work queue delay to zero.
- get rid of klp_schedule_work() in favor of calling schedule_delayed_work() directly with a KLP_TRANSITION_DELAY
- initialize klp_target_state to KLP_UNDEFINED
- move klp_target_state assignment to before patch->immediate check in klp_init_transition()
- rcu_read_lock() in klp_update_patch_state(), test the thread flag in patch task, synchronize_rcu() in klp_complete_transition()
- use kstrtobool() in enabled_store()
- change task_rq_lock() argument type to struct rq_flags
- add several WARN_ON_ONCE assertions for klp_target_state and task->patch_state

v2:
- "universe" -> "patch state"
- rename klp_update_task_universe() -> klp_patch_task()
- add preempt IRQ tracking (TF_PREEMPT_IRQ)
- fix print_context_stack_reliable() bug
- improve print_context_stack_reliable() comments
- klp_ftrace_handler comment fixes
- add "patch_state" proc file to tid_base_stuff
- schedule work even for !RELIABLE_STACKTRACE
- forked child inherits patch state from parent
- add detailed comment to livepatch.h klp_func definition about the klp_func patched/transition state transitions
- update exit_to_usermode_loop() comment
- clear all TIF_KLP_NEED_UPDATE flags in klp_complete_transition()
- remove unnecessary function externs
- add livepatch documentation, sysfs documentation, /proc documentation
- /proc/pid/patch_state: -1 means no patch is currently being applied/reverted
- "TIF_KLP_NEED_UPDATE" -> "TIF_PATCH_PENDING"
- support for s390 and powerpc-le
- don't assume stacks with dynamic ftrace trampolines are reliable
- add _TIF_ALLWORK_MASK info to commit log

v1.9:
- revive from the dead and rebased
- reliable stacks!
- add support for immediate consistency model
- add a ton of comments
- fix up memory barriers
- remove "allow patch modules to be removed" patch for now, it still needs more discussion and thought - it can be done with something
- "proc/pid/universe" -> "proc/pid/patch_status"
- remove WARN_ON_ONCE from !func condition in ftrace handler -- can happen because of RCU
- keep klp_mutex private by putting the work_fn in core.c
- convert states from int to boolean
- remove obsolete '@state' comments
- several header file and include improvements suggested by Jiri S
- change kallsyms_lookup_size_offset() errors from EINVAL -> ENOENT
- change proc file permissions S_IRUGO -> USR
- use klp_for_each_object/func helpers

Jiri Slaby (1):
livepatch/s390: reorganize TIF thread flag bits

Josh Poimboeuf (12):
stacktrace/x86: add function for detecting reliable stack traces x86/entry: define _TIF_ALLWORK_MASK flags explicitly
livepatch: create temporary klp_update_patch_state() stub livepatch/x86: add TIF_PATCH_PENDING thread flag livepatch/powerpc: add TIF_PATCH_PENDING thread flag
livepatch: separate enabled and patched states
livepatch: remove unnecessary object loaded check
livepatch: move patching functions into patch.c
livepatch: use kstrtobool() in enabled_store()
livepatch: store function sizes
livepatch: change to a per-task consistency model
livepatch: add /proc/<pid>/patch_state

Miroslav Benes (2):
livepatch/s390: add TIF_PATCH_PENDING thread flag
livepatch: allow removal of a disabled patch

 Documentation/ABI/testing/sysfs-kernel-livepatch |   8 +
 Documentation/filesystems/proc.txt               |  18 +
 Documentation/livepatch/livepatch.txt            | 214 +++++++--
 arch/Kconfig                                     |   6 +
 arch/powerpc/include/asm/thread_info.h           |   4 +-
 arch/powerpc/kernel/signal.c                     |   4 +
 arch/s390/include/asm/thread_info.h              |  24 +-
 arch/s390/kernel/entry.S                         |  31 +-
 arch/x86/Kconfig                                 |   1 +
 arch/x86/entry/common.c                          |   9 +-
 arch/x86/include/asm/thread_info.h               |  13 +-
 arch/x86/include/asm/unwind.h                    |   6 +
 arch/x86/kernel/stacktrace.c                     |  96 +++-
 arch/x86/kernel/unwind_frame.c                   |   2 +
 fs/proc/base.c                                   |  15 +
 include/linux/init_task.h                        |   9 +
 include/linux/livepatch.h                        |  68 ++-
 include/linux/sched.h                            |   3 +
 include/linux/stacktrace.h                       |   9 +-
 kernel/fork.c                                    |   3 +
 kernel/livepatch/Makefile                        |   2 +-
 kernel/livepatch/core.c                          | 436 +++++++-----------
 kernel/livepatch/patch.c                         | 272 +++++++++++
 kernel/livepatch/patch.h                         |  33 ++
 kernel/livepatch/transition.c                    | 551 +++++++++++++++++++++++
 kernel/livepatch/transition.h                    |  14 +
 kernel/sched/idle.c                              |   4 +
 kernel/stacktrace.c                              |  12 +-
 samples/livepatch/livepatch-sample.c             |  18 +-
 29 files changed, 1531 insertions(+), 354 deletions(-)
 create mode 100644 kernel/livepatch/patch.c
 create mode 100644 kernel/livepatch/patch.h
 create mode 100644 kernel/livepatch/transition.c
 create mode 100644 kernel/livepatch/transition.h
Signature · 1 line
2.7.4