Livepatch Background

kpatch-build工具和livepatch原理分析 内核kpatch机制是函数级的热替换技术,主要包含四大主件: kpatch-build:用于将源码patch生成ko热补丁 patch module:指生成的ko热补丁,包括需要新的函数和被替换函数的记录信息 kpatch core module: kpatch核心代码模块,为新旧函数热替换提供接口,使用kpatch时候是kpatch.ko模块,使用livepatch的时候不存在,因为内核已经支持livepatch kpatch utility: ... 阅读详情

Livepatch Related Work

From KShot1

Existing live patching focuses on open-source operating systems, mainly Linux.
For example, Ksplice 2, kpatch 3, and kGraft 4 can effectively patch security vulnerabilities without causing a significant downtime.
Kpatch and Ksplice both stop the running OS and ensure that none of the processes are affected by changes induced by patched functions.
Specifically, kpatch replaces the whole functions with patch ones, and Ksplice patches individual instructions instead of functions.
kGraft patches vulnerabilities at function level, but does not need to stop the running processes.
It maintains the original and patched function simultaneously and decides which one to execute by monitoring the state of processes, potentially inducing incorrect behavior or consuming additional storage.
These methods cannot address changes to data structures.
To address this limitation, KUP 5 replaces the whole kernel with a patched version, but uses checkpoint-and-restore to maintain application state consistency.
However, it checkpoints all the user processes, leading to large CPU and memory overhead.
KARMA 6 uses a kernel module to replace vulnerable instructions that it identifies from a given patch diff.

In addition, several live updating methods have been integrated into operating systems, like Canonical Livepatch Service 7 in Ubuntu, and Proteos 8 on MINIX 3, which can update new components if the patch is small. However, these methods still rely on the trustworthy operation of the target OS, so potential kernel-level attacks may tamper with the live patching operation, leading to system failure. KSHOT addresses this by leveraging a TEE to reliably patch the target kernel with a smaller TCB and low total overhead.

Preliminary

Hot Patch history 9

 DDJ: And when you had to hot-patch in flight?

GR: That's standard procedure. You always build in the ability to change it.

DDJ: Just in case.

GR: Just in case, but JPL and a bunch of decent-sized companies have had the problem where you can't get all the software done in time for launch. You always make sure you build the capability to change things.

I. kprobe

A kernel probe is a set of handlers placed on a certain instruction address. There are two types of probes in the kernel as of now, called “KProbes” and “JProbes.”

KProbes is a debugging mechanism for the Linux kernel which can also be used for monitoring events inside a production system.
A KProbe is defined by a pre-handler and a post-handler. When a KProbe is installed at a particular instruction and that instruction is executed, the pre-handler is executed just before the execution of the probed instruction. Similarly, the post-handler is executed just after the execution of the probed instruction.
Users can insert their own probe inside a running kernel by writing a kernel module which implements the pre-handler and the post-handler for the probe. In case a fault occurs while executing a probe handler function, the user can handle the fault by defining a fault-handler and passing its address in struct kprobe.
KProbes heavily depends on processor architecture specific features and uses slightly different mechanisms depending on the architecture on which it’s being executed.
KProbes is available on the following architectures however: ppc64, x86_64, sparc64 and i386.

JProbes are used to get access to a kernel function’s arguments at runtime. A JProbe is defined by a JProbe handler with the same prototype as that of the function whose arguments are to be accessed. When the probed function is executed the control is first transferred to the user-defined JProbe handler, followed by the transfer of execution to the original function.

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ns3IuvGf-1620477632848)(https://static.lwn.net/images/ns/kernel/KProbesArchitecture.png)]
The figure above describes the architecture of KProbes. On the x86, KProbes makes use of the exception handling mechanisms and modifies the standard breakpoint, debug and a few other exception handlers for its own purpose. Most of the handling of the probes is done in the context of the breakpoint and the debug exception handlers which make up the KProbes architecture dependent layer. The KProbes architecture independent layer is the KProbes manager which is used to register and unregister probes. Users provide probe handlers in kernel modules which register probes through the KProbes manager.

Interface
  • Data Structure
/*<linux/kprobes.h>*/
struct kprobe {
    struct hlist_node hlist;                    /* Internal */
    kprobe_opcode_t addr;                       /* Address of probe */
    kprobe_pre_handler_t pre_handler;           /* Address of pre-handler */
    kprobe_post_handler_t post_handler;         /* Address of post-handler */
    kprobe_fault_handler_t fault_handler;       /* Address of fault handler */
    kprobe_break_handler_t break_handler;       /* Internal */
    kprobe_opcode_t opcode;                     /* Internal */        
    kprobe_opcode_t insn[MAX_INSN_SIZE];        /* Internal */
};
struct jprobe {
    struct kprobe kp;
    kprobe_opcode_t *entry; 	/* user-defined JProbe handler address */
};
  • Register Method
typedef int (*kprobe_pre_handler_t)(struct kprobe*, struct pt_regs*);
typedef void (*kprobe_post_handler_t)(struct kprobe*, struct pt_regs*, 
              unsigned long flags);
typedef int (*kprobe_fault_handler_t)(struct kprobe*, struct pt_regs*, 
             int trapnr);
  • Kprobes Management

void lock_kprobes(void)
    Locks KProbes and records the CPU on which it was locked

void unlock_kprobes(void)
    Resets the recorded CPU and unlocks KProbes

struct kprobe *get_kprobe(void *addr)
    Using the address of the probed instruction, returns the probe from hash table

int register_kprobe(struct kprobe *p)
    This function registers a probe at a given address. Registration involves copying the instruction at the probe address in a probe specific buffer. On x86 the maximum instruction size is 16 bytes hence 16 bytes are copied at the given address. Then it replaces the instruction at the probed address with the breakpoint instruction.

void unregister_kprobe(struct kprobe *p)
    This function unregisters a probe. It restores the original instruction at the address and removes the probe structure from the hash table.

int register_jprobe(struct jprobe *jp)
    This function registers a JProbe at a function address. JProbes use the KProbes mechanism. In the KProbe pre_handler it stores its own handler setjmp_pre_handler and in the break_handler stores the address of longjmp_break_handler. Then it registers struct kprobe jp->kp by calling register_kprobe()

void unregister_jprobe(struct jprobe *jp)
    Unregisters the struct kprobe used by this JProbe
Trigger
  • Kprobes
    After the probes are registered, the addresses at which they are active contain the breakpoint instruction (int3 on x86). As soon as execution reaches a probed address the int3 instruction is executed, causing the control to reach the breakpoint handler do_int3() in arch/i386/kernel/traps.c. do_int3() is called through an interrupt gate therefore interrupts are disabled when control reaches there. This handler notifies KProbes that a breakpoint occurred; KProbes checks if the breakpoint was set by the registration function of KProbes. If no probe is present at the address at which the probe was hit it simply returns 0. Otherwise the registered probe function is called.
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-09XjYuXg-1620477632854)(https://static.lwn.net/images/ns/kernel/KProbeExecution.png)]

  • JProbes
    In the first step, when the breakpoint is hit control reaches kprobe_handler() which calls the JProbe pre-handler (setjmp_pre_handler()). This saves the stack contents and the registers before changing the eip to the address of the user-defined function. Then it returns 1 which tells kprobe_handler() to simply return instead of setting up single-stepping as for a KProbe. On return control reaches the user-defined function to access the arguments of the original function. When the user defined function is done it calls jprobe_return() instead of doing a normal return.
    In the second step jprobe_return() truncates the current stack frame and generates a breakpoint which transfers control to kprobe_handler() through do_int3(). kprobe_handler() finds that the generated breakpoint address (address of int3 instruction in jprobe_handler()) does not have a registered probe however KProbes is active on the current CPU. It assumes that the breakpoint must have been generated by JProbes and hence calls the break_handler of the current_kprobe which it saved earlier. The break_handler restores the stack contents and the registers that were saved before transferring control to the user-defined function and returns.
    In the third step kprobe_handler() then sets up single-stepping of the instruction at which the JProbe was set and the rest of the sequence is the same as that of a KProbe.
    [外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-DQS6ZfC6-1620477632861)(https://static.lwn.net/images/ns/kernel/JProbeExecution.png)]

Weakness

There could be several possible problems which could occur when a probe is handled by KProbes. The first possibility is that several probes are handled in parallel on a SMP system.
However, there’s a common hash table shared by all probes which needs to be protected against corruption in such a case. In this case kprobe_lock serializes the probe handling across processors.

Another problem occurs if a probe is placed inside KProbes code, causing KProbes to enter probe handling code recursively.
This problem is taken care of in kprobe_handler() by checking if KProbes is already running on the current CPU.
In this case the recursing probe is disabled silently and control returns back to the previous probe handling code.

If preemption occurs when KProbes is executing it can context switch to another process while a probe is being handled.
The other process could cause another probe to fire which will cause control to reach kprobe_handler() again while the previous probe was not handled completely.
This may result in disarming the new probe when KProbes discovers it’s recursing.
To avoid this problem, preemption is disabled when probes are handled.

Similarly, interrupts are disabled by causing the breakpoint handler and the debug handler to be invoked through interrupt gates rather than trap gates.
This disables interrupts as soon as control is transferred to the breakpoint or debug handler.
These changes are made in the file arch/i386/kernel/traps.c.

A fault might occur during the handling of a probe.
In this case, if the user has defined a fault handler for the probe, control is transferred to the fault handler.
If the user-defined fault handler returns 0 the fault is handled by the kernel.
Otherwise, it’s assumed that the fault was handled by the fault handler and control reaches back to the probe handlers.

KProbes however cannot be used directly for these purposes.
In the raw form a user can write a kernel module implementing the probe handlers.
However higher level tools are necessary for making it more convenient to use.
Such tools could contain standard probe handlers implementing the desired features or they could contain a means to produce probe-handlers given simple descriptions of them in a scripting language like DProbes.

II. ftrace

Interface

III. strace

Interface

IV. ebpf

Interface

V.

State of Art

Ksplice2

Introduction

See pdf10
Especially,Ksplice starts with a call to stop_machine_run(), which dumps a high-priority thread onto each processor, thus taking control of all processors in the system.
It then examines all threads in the system to ensure that none of them are running in the functions to be replaced; if so, trampoline jumps are patched into the beginning of each replaced function (they “bounce” the call to the old code into the replacement code) and life continues.
Otherwise ksplice will back off and try again later.

Limitations
  • Only Code. data structures are out of scope.
    solution:
    • personal preparing,ksplice_apply(void (*func)())
      While Ksplice is applying the changes - and while the rest of the system is still stopped - the given func will be called. It can then go rooting through the kernel’s data structures, changing things as needed.
  • Retry-based approach to ensring that no threads are running in the patched functions. It mightly always waits.
Additional Talking

It’s simple to satisfy the demand of structure field removing. However, things come to complicated when we need to put addition of a new filed. “Shadow” mechanism is applied to solve this. It allocates a separate structure to hold the new filed. Bring out some challenges as well:

  • the original patch must be changed in a number of places.
  • Code which allocates the affected structure must be modified to allocate the shadow as well, and code which frees the structure must be changed in similar ways.
  • Any reference to the new field(s) must, instead, look up the shadow structure and use that version of the field. All told, it looks like a tiresome procedure which has a significant chance of introducing new bugs.
  • There is also the potential for performance issues caused by the linear linked list search performed to find the shadow structures.
KReplace

Based on jprobe but only function-orientated and even harder to use than Ksplice.
see 11 12

KGraft

Introduction

KGraft is the work of Jiří Kosina and Jiří Slaby, both working at SUSE. The approach they have taken is simpler than Ksplice, and lacks some of the capabilities that Ksplice offers (adding shadow members to structures, for example). On the other hand, the basic kGraft code is only a 600-line patch, and the process of applying a patch is quite a bit more lightweight, with less impact on the system.
KGraft works by replacing entire functions in the kernel. Using the tools supplied with the patch set, a developer can turn a patch into a list of changed functions; the new versions of those functions are then compiled into a separate kernel module. When that module is loaded into the kernel, kGraft takes care of the task of replacing the existing, buggy functions with the new, fixed versions.

Hazards
  1. Cheif hazard is this: what happens if a process is running in kernel during the patch is applying?
    Solution: Marker in thread_info to separate processes into “old universe” and “new universe”.

  2. What about processes that don’t make this transition in a reasonable period of time? For example, a process stuck waitting for I/O on a network socket.
    Solution: a flag under /proc allowing the system administrator to identify processes that are gumming up the works.

  3. What about kernel threads, which have no user space to return to?
    Solution: Most thread call kthread_should_stop() to exit, the left inserted with kgr_task_safe().(old->new universe)

  4. Interrupts block globally?
    Solution: kGraft can block interrupts on the local CPU while it’s making its changes, but cannot work globally.
    kGraft adds a per-CPU array to track whether each processor has run in process (non-interrupt) context.
    That flag is initially set to false, and schedule_on_each_cpu() is called to run a kGraft function, in process context, on each processor. That function, which cannot run until any pending interrupts on a given CPU have been serviced, will set the per-CPU flag. The function-replacement stub, meanwhile, will force interrupt code to run in the old universe on any CPU that has not yet set its per-CPU “new universe” flag.

  5. Inner-data
    do a “flip and forget” switch between functions that expect different
    format of in-memory data without performing a non-trivial all-memory
    lookup to find structures in question and perfoming corresponding
    transformations.13
    Two Steps:
    (1). redirect to a temporary band-aid function that can handle both
    semantics of the data (presumably in highly sub-optimal way)
    (2). patching in (1) succeeds completely (kGraft claims victory), start a
    new round of patching with redirect to the final function which expects only the new semantics

kPatch

Like kGraft, kpatch replaces entire functions within a running kernel. A kernel patch is processed to determine which functions it changes; the kpatch tools (not included with the patch, but available in this repository) then use that information to create a loadable kernel module containing the new versions of the changed functions.
A call to the new kpatch_register() function within the core kpatch code will use the ftrace function tracing mechanism to intercept calls to the old functions, redirecting control to the new versions instead.
It starts by calling stop_machine() to bring all other CPUs in the system to a halt.
Then, kpatch examines the stack of every process running in kernel mode to ensure that none are running in the affected function(s); should one of the patched functions be active, the patch-application process will fail.
If things are OK, instead, kpatch patches out the old functions completely (or, more precisely, it leaves an ftrace handler in place that routes around the old function).
There is no tracking of whether processes are in the “old” or “new” universe; instead, everybody is forced to the new universe immediately if it is possible.(stop_machine() is a massive sledgehammer14 and should be avoid using it.)

FATAL ISSUE: If kernel code is RUNNING inside one of the target functions, kpatch will simply FAIL.
And Ingo15 suggested that, how about achieving an even ‘cleaner’ state for all tasks in the system: to freeze all tasks, as the suspend and hibernation code (and kexec) does, via freeze_processes()?
Frederic Weisbecker15 suggested that the kernel thread parking mechanism.16

Inner-data: The plan for the near future is to add a callback that can be packaged with a live patch; its job would be to search out and convert all affected data structures while the system is stopped and the patch is being applied. This approach has the potential to work without the need for maintaining the ability to cope with older data structures, but only if all of the affected structures can be located at patching time — a tall order, in many cases. And they claim that only few patches make changes to kernel data structures.17

Livepatch

The code merged for 4.0 is a common core that is able to support patching with both kpatch and kGraft. It provides an API that allows patch-containing modules to be inserted into the kernel; it also allows the listing and removal of patches if need be. This API performs the low-level redirection needed to replace patched functions.
But it’s missing an important component, called the “consistency model”, that ensures the safety of switching between versions of a function in a running kernel.

Unified Consistency Model18

This approach retains the two-universe model from kGraft, but it uses the stack-trace checking from kpatch to accelerate the task of switching processes to the new code.
In theory, this technique increases the chances of successfully applying patches while doing away with kpatch’s disruptive stop_machine() call and much of kGraft’s higher code complexity.

When patching, tasks are carefully transitioned from the old universe to the new universe. A task can only be switched to the new universe if it’s not using a function that is to be
patched or unpatched. After all tasks have moved to the new universe, the
patching process is complete.

How it transitions various tasks to the new universe:

  • The stacks of all sleeping tasks are checked. Each task that is not sleeping
    on a to-be-patched function is switched.
  • Other user tasks are handled by do_notify_resume() (see patch 9/9). If a
    task is I/O bound, it switches universes when returning from a system call.
    If it’s CPU bound, it switches when returning from an interrupt. If it’s
    sleeping on a patched function, the user can send SIGSTOP and SIGCONT to
    force it to switch upon return from the signal handler.
  • Idle “swapper” tasks which are sleeping on a to-be-patched function can be
    switched from within the outer idle loop.
  • An interrupt handler will inherit the universe of the task it interrupts.
  • kthreads which are sleeping on to-be-patched functions are not yet handled
    (more on this below).

advantages vs kpatch:

  • no stop machine latency
  • higher patch success rate (can patch in-use functions)
  • patching failures are more predictable (primary failure mode is attempting to
    patch a kthread which is sleeping forever on a patched function, more on this
    below)

advantages vs kGraft:

  • less code complexity (don’t have to hack up the code of all the different
    kthreads)
  • less impact to processes (don’t have to signal all sleeping tasks)

disadvantages vs kpatch:

  • no system-wide switch point (not really a functional limitation, just forces
    the patch author to be more careful. but that’s probably a good thing anyway)

My biggest concerns and questions related to this patch set are:

  1. To safely examine the task stacks, the transition code locks each task’s rq
    struct, which requires using the scheduler’s internal rq locking functions.
    It seems to work well, but I’m not sure if there’s a cleaner way to safely
    do stack checking without stop_machine().

  2. As mentioned above, kthreads which are always sleeping on a patched function
    will never transition to the new universe. This is really a minor issue
    (less than 1% of patches). It’s not necessarily something that needs to be
    resolved with this patch set, but it would be good to have some discussion
    about it regardless.

    To overcome this issue, I have 1/2 an idea: we could add some stack checking
    code to the ftrace handler itself to transition the kthread to the new
    universe after it re-enters the function it was originally sleeping on, if
    the stack doesn’t already have have any other to-be-patched functions.
    Combined with the klp_transition_work_fn()'s periodic stack checking of
    sleeping tasks, that would handle most of the cases (except when trying to
    patch the high-level thread_fn itself).

    But then how do you make the kthread wake up? As far as I can tell,
    wake_up_process() doesn’t seem to work on a kthread (unless I messed up my
    testing somehow). What does kGraft do in this case?

Objections

It comes down to the fact that getting a reliable stack trace out of a process
running in kernel space is not as easy as one might expect. So stack unwinding is not absolutly safe.
Trackback code stay out of sight until some distributro issues a live patch, at
which point things will go badly wrong. And it also is a risk that will always hard to avoid,
since the correct functioning of the kernel does not otherwise depend on perfectly
accurate stack traces.

Except Stack Traceback:

  • Force every process in the system into a quiescent, non-kernel state before
    applying a patch.19 (But kernel thread cannot be pushed out of kernel space.)
  • KGraft’s two universes model.(The downside with this approach is that the process of trapping every process in a safe place can take an unbounded period of time during which the system is in a weird intermediate state.)
Alternative Solution
CRIU-seamless

The developers working on CRIU (checkpoint-restore in user space) have had
seamless kernel upgrades20 in their list of use cases for a while, and
they evidently have it working for some workloads.
They just save the entire state of the system, boot into an entirely new kernel,
then restore the previous state on top of the new kernel.
For some use cases, it might make sense to checkpoint all of the user-space processes,
kexec() to the new kernel, then restore all of user space.
That would allow changing to a completely new kernel, but it would not be
immediate (or live). It also would reinitialize the hardware, which may not be desirable.

[AT&T/Lucent Unix RTR System]:https://lwn.net/Articles/735186/
[Nortel’s wireline switch]:https://lwn.net/Articles/802295/

a branch (to the new code) was inserted as the first instruction of the old function,
while keeping a copy of the old function around just in case you wanted to unpatch.
This so long, as there was no alteration to global variables etc. and the
changes were restricted to code within the old function.
If you needed to fully replace a module binary, you’d that option too, but
depending on the type of changes, you might have needed a restart to complete the operation.

Later work

There were competing solutions, so a meeting was held at the 2014 LPC in Düsseldorf to
discuss the matter.
Each solution was presented and the developers came up with a plan to try to merge one unified scheme.
It would start with a minimal base on top of Ftrace, with a simple API.
Live patches could be registered with a list of functions to be replaced,
and it only supported a limited set of patch types that could be applied.

That was merged into the mainline in February 2015.

Since then, ideas have been cherry-picked from kpatch and kGraft to be added
to the kernel under the CONFIG_LIVEPATCH option.
There is now a combined, hybrid consistency model that uses lazy migration by
default, but falls back to stack examination for long-sleeping processes and kthreads.
Originally, the feature was x86-only, but it has been added to s390 and PowerPC-64, with ARM64 in the works.

Update of stack examination
  • Earlier efforts at getting reliable stack traces either used frame pointers,
    which had a severe performance penalty, or DWARF debugging records, which
    turned out to be unreliable and slow.
    ORC is effectively a stripped-down version of DWARF that has nothing more than
    is needed for reliable stack unwinding.
    The ORC unwinder was merged into 4.14 and will also be used for oops and panic output.
    So far, it is only available for x86_64, but is in progress for other architectures;
    the main work is on objtool, Kosina said, as the ORC unwinder is straightforward to port.
  • ensure that assembly language pieces of the kernel will also produce a valid stack trace.
Objective
  • Competent
  • Compatible
  • Secure

More to do 21

  • Modifications of data structures.
  • Optimizations like GCC -fipr-ra would change the ABI for function they known, while patches
    cannot be handled.
  • Kprobes cannot switch an existing kprobe to a new function. There is a inability to
    patch hand-written assembly code. Ftrace is not able to work with that code.
  • User space application might built with tools other than GCC. which expands the problem. Ftrace
    is not able to deal with this situation.
  • It’s also harder to define a checkpoint where the consistency can be assured.

References


  1. KShot: Live Kernel Patching with SMM and SGX,2020 ↩︎

  2. ORACLE, “Ksplice,” http://www.ksplice.com/, 2018. ↩︎ ↩︎

  3. J. Poimboeuf and S. Jennings, “Introducing kpatch: dynamic kernel
    patching,” Red Hat Enterprise Linux Blog, vol. 26, 2014. ↩︎

  4. SUSE, “Live Patching the Linux Kernel Using kGraft,” https://www.suse.com/documentation/sles-15/book_sle_admin/data/cha_kgraft.html, 2018. ↩︎

  5. S. Kashyap, C. Min, B. Lee, T. Kim, and P. Emelyanov, “Instant
    OS updates via userspace checkpoint-and-restart.” in USENIX Annual
    Technical Conference, 2016. ↩︎

  6. Y. Chen, Y. Zhang, Z. Wang, L. Xia, C. Bao, and T. Wei, “Adaptive Android kernel live patching,” in Proceedings of the 26th USENIX Security Symposium, 2017. ↩︎

  7. Ubuntu, “Canonical Livepatch Service,” https://www.ubuntu.com/livepatch, 2018. ↩︎

  8. C. Giuffrida, A. Kuijsten, and A. S. Tanenbaum, “Safe and automatic live update for operating systems,” in ACM SIGARCH Computer Architecture News, vol. 41, no. 1. ACM, 2013, pp. 279–292. ↩︎

  9. https://www.drdobbs.com/a-conversation-with-glenn-reeves/184411097 ↩︎

  10. http://web.mit.edu/ksplice/doc/ksplice.pdf ↩︎

  11. https://lwn.net/Articles/308236/ ↩︎

  12. https://lwn.net/Articles/308421/ ↩︎

  13. https://lwn.net/Articles/597426/ ↩︎

  14. https://lwn.net/Articles/597407/ ↩︎

  15. https://lwn.net/Articles/597421/ ↩︎ ↩︎

  16. https://lwn.net/Articles/500338/ ↩︎

  17. https://lwn.net/Articles/597430/ ↩︎

  18. https://lwn.net/Articles/632582/ ↩︎

  19. https://lwn.net/Articles/634660/ ↩︎

  20. http://criu.org/Usage_scenarios#Seamless_kernel_upgrade ↩︎

  21. https://lwn.net/Articles/734765/ ↩︎

linux 热补丁机制基本概念 内核实现 livepatch 对架构,编译器等均有一些要求,比如编译器为架构提供可靠栈回溯,支持动态 ftrace regs 等,否则对应架构很难实现 livepatch,目前有 x86,powerpc,s390 能在内核直接支持 livepatch。kpatch 修补的单位是函数,而不是数据结构,如果补丁对数据结构进行了修改,那一般会出问题,需要重新制作补丁,默认不允许修改数据结构,如果这样做了,kpatch-build 可能会抛出错误。字符串,从打印中可以看到补丁应用成功,卸载补丁后恢复原来的字符串。 阅读详情

相关推荐

Livepatch —— 免重启给 Ubuntu Linux 内核打关键性安全补丁

导读 在你的 Ubuntu 服务器上启用了 Livepatch,你就可以在保证系统安全的同时把计划内的外的停机时间降到最低。 -注册 Ubuntu Livepatch 账号22% -获取并使用 Livepatch 令牌47% 如果你是一个在企业环境中维护关键性系统的系统管理员,你肯定对以下两件事深有感触: 1) 很难找个停机时间去给系统安装安全补丁以修复内核或

Jack__CJ的博客 9628

如何在Ubuntu上使用Canonical的Livepatch服务

Fancy having critical Linux kernel patches automatically applied to your Ubuntu system—without having to reboot your computer? We describe how to use Canonical’s Livepatch Service to do just that. 想将重...

cum44153的博客 7808

保姆级教程:在MMSegmentation框架下复现HRNetV2+OCR语义分割(附完整代码与调试技巧)

本文提供了一份详细的MMSegmentation框架下HRNetV2+OCR语义分割的复现教程,包含完整代码与调试技巧。通过解析HRNetV2的多尺度特征融合和OCR模块的注意力计算,帮助开发者快速实现这一经典语义分割方案,并解决实际工程中的常见问题。

weixin_42527464的博客 359

Livepatch: Linux kernel updates without rebooting

Livepatch: Linux kernel updates without rebooting - Linux AuditLivepatch is a feature to do live kernel patching for Linux systems. It allows applying security updates without rebooting the system. Learn how it works!https://linux-audit.com/livepatch-linux

RToax 976

C# CAD2016 多边形顶点按方向重新排序

这样,通过以上步骤,我们找到了一个多边形的一个候选起始顶点(可能位于西北方向),并且已经获取了该多边形的边界框信息,这些信息对于后续判断顶点排列顺序及处理其他相关问题具有重要意义。完整地处理八个方向(东北、东南、西南、西北、北、南、东、西),我们可以创建一个方法来获取多边形相对于给定点的最近顶点及其对应的方向。对象(或类似的多边形表示方式),其中包含了多边形的顶点。//附送AI 图片无版权 随意用 龙年大吉大利。

转眼之间 一路有你 1355

AI气象预报:数值模式融合与短临预警的工程实践

气象预报正经历从物理推演到数据驱动的认知范式转变。AI气象预报并非替代传统数值模式,而是通过数值模式融合弥补其在参数化误差、初值敏感性和计算效率上的固有瓶颈。其技术价值在于提升短临预警时效性与空间精度,支撑航空调度、电力调控、防洪应急等关键场景。实践中需兼顾物理一致性、可解释性与业务系统兼容性,避免纯黑箱建模带来的外推失效与不确定性缺失风险。本文聚焦AI作为超分辨率引擎、误差矫正器和短临加速器的三类落地路径,解析HEALPix投影、多尺度图建模、轻量级U-Net等核心适配方法。

weixin_28221501的博客 298

【Ubuntu 20.04 LTS】详细安装

文章目录安装镜像下载制作安装U盘开始安装 安装 镜像下载 https://cn.ubuntu.com/download/desktop 点击下载 制作安装U盘 制作U盘启动盘的方式有很多,比如软碟通、Rufus等,本文使用的是对新手比较友好的balenaEtcher。 下载地址 https://www.balena.io/etcher/ 官网地址下载比较慢,可以通过下方的资源链接进行下载 链接:https://pan.baidu.com/s/1JrElEydZFE3sZK_j1vGZaw 提取码

猫巳的博客 7301

Star CCM+中衍生零部件下的阈值应用与区域内删除目标网格

同样的在绘制网格结束后,有时出现负体积网格或质量差的网格,为了节约时间成本,可能会选择将负体积的网格或质量差的网格删除。弹出相应的窗口,在窗口中选择相应的区域①,选择标量函数②(此处以网格体积变化为例),选择模型③,设置阈值④,选择No Dispalyer,会根据需求选择显示,最后点击Create⑥完成创建。此处以温度为例,若出现温度异常点,首先在①栏中勾选Function,然后在下面点击⑤Select,在弹出的Function窗口中选择温度场函数,再点击④Identify,查找温度异常网格数量。

2201_75375391的博客 2222

Linux内核热补丁实现方式及原理

linux内核热补丁

qq_25346431的博客 1191

基于cnn version_transformer VIT模型的动物图像分类 完整代码+数据 动物分类教程

基于cnn version_transformer VIT模型的动物图像分类 完整代码+数据 动物分类教程

机器学习深度学习业余选手 1001

Python基础语法与最佳实践【python基础篇】

本文全面介绍了Python基础语法与最佳实践,涵盖变量与数据类型、控制流、函数、模块与包等核心概念。通过实际代码示例展示了条件语句、循环结构、函数定义及模块导入的基本用法。在最佳实践部分,重点讲解了PEP 8代码风格规范、异常处理技巧、列表推导式、上下文管理器、文档字符串编写以及enumerate和zip的高效使用。这些内容既适合Python初学者掌握基础语法,也能帮助有经验的开发者编写更规范、高效、可维护的代码。文章强调遵循Python官方推荐实践,通过合理运用语言特性提升代码质量。

博客 1975

Linux内核show_stack,Linux内核kpatch快速参考

1kpatch介绍1.1kpatch概览kpatch 是一个动态的内核补丁技术, 它可以直接让你对一个正在运行的内核打补丁而不需要进行系统重启. 对于系统管理员来说,他/她可以更从容安排系统维护计划.1.2kpatch是如何工作的.kpatch 通过内核的ftrace机制,对被打补丁的内核函数进行重定向;当被打补丁的函数被调用时,通过函数代码段预留的钩子,进而重定向到补丁函数,执行完毕后,再返回初...

weixin_31040783的博客 1403

【OpenClaw从入门到精通】第73篇:30天OpenClaw实战挑战——从零搭建个人数字助理(Day15-21)万字超详细高阶实战版

经过前两周的基础部署与功能搭建,你已拥有可自动化干活的AI助理与数字员工团队,但距离“高阶精通”仍有差距。本文聚焦第三周(Day15-21)核心实战,围绕安全审计、语音能力接入、Token成本控制、Agent Loop优化、One-Liner指令五大核心模块,结合真实落地案例与踩坑经验,提供超详细实操指南。通过本文,你将掌握生产级安全加固方案、语音交互全流程配置、低成本高性价比使用策略、Agent自主闭环优化技巧,以及一句话搞定复杂任务的高效指令用法,同时完成中期复盘与最后九天冲刺规划

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 362

(非常详细的livepatch解析)热补丁技术原理之---3.livepatch原理解析

本文详细介绍了livepatch的加载卸载原理

wardenjohn的博客 4478

Matlab基于PSO-MVMD粒子群算法优化多元变分模态分解

Matlab基于PSO-MVMD粒子群算法优化多元变分模态分解

机器学习之心的博客,关注并私信文章链接,获取对应文章源码和数据。 517

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

如何在Ubuntu 20.04上安装Linux,Nginx,MySQL,PHP(LEMP堆栈)

介绍 (Introduction) The LEMP software stack is a group of software that can be used to serve dynamic web pages and web applications written in PHP. This is an acronym that describes a Linux operating s...

836

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

kpatch 热修 ipvs estimation_timer 内核延时问题

1. kpatch 是什么? livepatch 实时或动态内核修补允许为正在运行的内核提供功能增强,无需重新启动系统,这对于某些在线系统修复安全漏洞非常有帮助。 Kpatch 是给 Linux 内核 livepatch 的工具,由 Redhat 公司出品。最早出现的打热补丁工具是 Ksplice。但是 Ksplice 被 Oracle 收购后,一些发行版生产商就不得不开发自己的热补丁工具,分别是 Redhat 的 Kpatch 和 Suse 的 KGraft。同时,在这两家厂商的推进下,kernel 4.

dwh0403的专栏 1066

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

DMA分配内存,能用那些函数,那些不能用?why? 因为 DMA物理地址要连续

这两天有空重读了ldd的第8章内存管理,这本书是很好,但是有的内容不太实用,下面结合工作需要把常用的内容作下总结。 注意:下文提到的 j-one 平台内存是 128M。 1. ioremap : ioremap 会按照页的大小调整映射size。另外,当地址没有页对齐的时候,ioremap会rounding down这个地址,也就是向下圆整地址,然后返回内存页的首地址+offset。下

wocao1226的专栏 3970

kpatch入门实践教程

1、基本原理以及使用教程,参考: https://github.com/dynup/kpatch/blob/meastr/README.md https://github.com/dynup/kpatch/blob/master/doc/patch-author-guide.md 2、测试环境: 系统:CentOS 7 内核版本:3.10.0-957.5.1.el7.x86_64 工具:gcc ...

lonely_geek的博客 3311

kpatch vs livepatch vs kGraft:三大Linux热补丁技术终极对比

在Linux系统运维中, kernel热补丁技术是保障系统持续运行的关键。kpatch、livepatch和kGraft作为主流的三大热补丁技术,各自有着独特的实现方式和适用场景。本文将深入对比这三种技术的核心差异,帮助你快速选择最适合业务需求的解决方案。 ## 技术原理与实现方式 ### kpatch:红帽主导的轻量化方案 kpatch是由红帽开发的内核热补丁工具,通过动态生成差异代码并加载

gitblog_00947的博客 1139

kpatch介绍

kpatch介绍 荣涛 2021年10月26日 文档修改日志 日期 修改内容 修改人 备注 2021年10月26日 新建 荣涛 1. 引言 1.1. 主要项目 项目 厂商 简介 自动化程度 工作级别 KSplice Oracle linux社区第一个热补丁项目,后被Oracle收购 全自动 指令集 Kpatch RedHat 代码开源,但是需要RHEL的license才可以使用 管理员 函数 Kgraft SUSE 在企业版SELS中提供 管理员 函数

RToax 1019

内核动态补丁(kpatch)及kpatch pushsection popsection previous的解释

内核动态补丁(katch)解释 本文阅读体验不好,因此做了pdf版本,点击下载,如果你没有分数,可以直接留言找我要pdf版本。 内核可以在运行时动态执行补丁中的代码(kpatch),而不需要重启后再运行补丁代码。对于kpatch的运行原理,可以参看[3], kpatch基于ftrace技术,可以在内核运行时动态的(即不需要重启)、整体替换某个函数(但需要暂时停止所有运行时进程)。如图1所示,具...

Heron——Linux & ARM 3559

loadrunner运行场景时,常见错误及解决方法

目录   1、Error -27727:. 3 2、Error -27728:. 3 3、Error -27791:. 3 4、Error -27492:. 4 5、Error -27498:. 4 6、Error -26612:. 4 7、Error -27496:. 5 8、Error -27995:. 5 9、Error -27279:... 5 10

yoyo_sunny的专栏 6万+

centos8 内核热补丁kpatch制作详解

0x00 测试环境 发行版:CentOS Linux release 8.0.1905 (Core) 内核版本:4.18.0-305.10.2.el8_4.x86_64 0x01. 准备kpatch 1.先从github上把kpatch工具下载一下 git clone GitHub - dynup/kpatch: kpatch - live kernel patching 2.进入到kpacth目录执行买这一步会安装好kpatch所需的依赖: source test/integrati

Be a bad guy!的专栏 2591

Cannot assign requested address出现的原因及解决方案

Cannot assign requested address出现的原因及解决方案

zhengxiuchen86的博客 3098

live patch 实例测试

在fs/proc/cmdline.c 中注册一个proc的接口,源码如下, static int cmdline_proc_show(struct seq_file *m, void *v) {     seq_printf(m, "%s\n", saved_command_line);     return 0; } static int cmdline_proc_open(st

jason的笔记 4102
上一篇: Compile-time stack validation for Livepatch
下一篇: Linux内核启动过程(Linux 2.4)
grsharp
博客等级 码龄12年 4粉丝 10原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值