@@ -4,22 +4,22 @@ Livepatch
44
55This document outlines basic information about kernel livepatching.
66
7- Table of Contents:
8-
9- 1. Motivation
10- 2. Kprobes, Ftrace, Livepatching
11- 3. Consistency model
12- 4. Livepatch module
13- 4.1. New functions
14- 4.2. Metadata
15- 5. Livepatch life-cycle
16- 5.1. Loading
17- 5.2. Enabling
18- 5.3. Replacing
19- 5.4. Disabling
20- 5.5. Removing
21- 6. Sysfs
22- 7. Limitations
7+ .. Table of Contents:
8+
9+ 1. Motivation
10+ 2. Kprobes, Ftrace, Livepatching
11+ 3. Consistency model
12+ 4. Livepatch module
13+ 4.1. New functions
14+ 4.2. Metadata
15+ 5. Livepatch life-cycle
16+ 5.1. Loading
17+ 5.2. Enabling
18+ 5.3. Replacing
19+ 5.4. Disabling
20+ 5.5. Removing
21+ 6. Sysfs
22+ 7. Limitations
2323
2424
2525 1. Motivation
@@ -40,14 +40,14 @@ There are multiple mechanisms in the Linux kernel that are directly related
4040to redirection of code execution; namely: kernel probes, function tracing,
4141and livepatching:
4242
43- + The kernel probes are the most generic. The code can be redirected by
43+ - The kernel probes are the most generic. The code can be redirected by
4444 putting a breakpoint instruction instead of any instruction.
4545
46- + The function tracer calls the code from a predefined location that is
46+ - The function tracer calls the code from a predefined location that is
4747 close to the function entry point. This location is generated by the
4848 compiler using the '-pg' gcc option.
4949
50- + Livepatching typically needs to redirect the code at the very beginning
50+ - Livepatching typically needs to redirect the code at the very beginning
5151 of the function entry before the function parameters or the stack
5252 are in any way modified.
5353
@@ -249,7 +249,7 @@ The patch contains only functions that are really modified. But they
249249might want to access functions or data from the original source file
250250that may only be locally accessible. This can be solved by a special
251251relocation section in the generated livepatch module, see
252- Documentation/livepatch/module-elf-format.txt for more details.
252+ Documentation/livepatch/module-elf-format.rst for more details.
253253
254254
2552554.2. Metadata
@@ -258,7 +258,7 @@ Documentation/livepatch/module-elf-format.txt for more details.
258258The patch is described by several structures that split the information
259259into three levels:
260260
261- + struct klp_func is defined for each patched function. It describes
261+ - struct klp_func is defined for each patched function. It describes
262262 the relation between the original and the new implementation of a
263263 particular function.
264264
@@ -275,7 +275,7 @@ into three levels:
275275 only for a particular object ( vmlinux or a kernel module ). Note that
276276 kallsyms allows for searching symbols according to the object name.
277277
278- + struct klp_object defines an array of patched functions (struct
278+ - struct klp_object defines an array of patched functions (struct
279279 klp_func) in the same object. Where the object is either vmlinux
280280 (NULL) or a module name.
281281
@@ -285,7 +285,7 @@ into three levels:
285285 only when they are available.
286286
287287
288- + struct klp_patch defines an array of patched objects (struct
288+ - struct klp_patch defines an array of patched objects (struct
289289 klp_object).
290290
291291 This structure handles all patched functions consistently and eventually,
@@ -337,14 +337,16 @@ operation fails.
337337Second, livepatch enters into a transition state where tasks are converging
338338to the patched state. If an original function is patched for the first
339339time, a function specific struct klp_ops is created and an universal
340- ftrace handler is registered[*] . This stage is indicated by a value of '1'
340+ ftrace handler is registered\ [ # ]_ . This stage is indicated by a value of '1'
341341in /sys/kernel/livepatch/<name>/transition. For more information about
342342this process, see the "Consistency model" section.
343343
344344Finally, once all tasks have been patched, the 'transition' value changes
345345to '0'.
346346
347- [*] Note that functions might be patched multiple times. The ftrace handler
347+ .. [# ]
348+
349+ Note that functions might be patched multiple times. The ftrace handler
348350 is registered only once for a given function. Further patches just add
349351 an entry to the list (see field `func_stack `) of the struct klp_ops.
350352 The right implementation is selected by the ftrace handler, see
@@ -368,7 +370,7 @@ the ftrace handler is unregistered and the struct klp_ops is
368370freed when the related function is not modified by the new patch
369371and func_stack list becomes empty.
370372
371- See Documentation/livepatch/cumulative-patches.txt for more details.
373+ See Documentation/livepatch/cumulative-patches.rst for more details.
372374
373375
3743765.4. Disabling
@@ -421,7 +423,7 @@ See Documentation/ABI/testing/sysfs-kernel-livepatch for more details.
421423
422424The current Livepatch implementation has several limitations:
423425
424- + Only functions that can be traced could be patched.
426+ - Only functions that can be traced could be patched.
425427
426428 Livepatch is based on the dynamic ftrace. In particular, functions
427429 implementing ftrace or the livepatch ftrace handler could not be
@@ -431,7 +433,7 @@ The current Livepatch implementation has several limitations:
431433
432434
433435
434- + Livepatch works reliably only when the dynamic ftrace is located at
436+ - Livepatch works reliably only when the dynamic ftrace is located at
435437 the very beginning of the function.
436438
437439 The function need to be redirected before the stack or the function
@@ -445,15 +447,15 @@ The current Livepatch implementation has several limitations:
445447 this is handled on the ftrace level.
446448
447449
448- + Kretprobes using the ftrace framework conflict with the patched
450+ - Kretprobes using the ftrace framework conflict with the patched
449451 functions.
450452
451453 Both kretprobes and livepatches use a ftrace handler that modifies
452454 the return address. The first user wins. Either the probe or the patch
453455 is rejected when the handler is already in use by the other.
454456
455457
456- + Kprobes in the original function are ignored when the code is
458+ - Kprobes in the original function are ignored when the code is
457459 redirected to the new implementation.
458460
459461 There is a work in progress to add warnings about this situation.
0 commit comments