Kernel Live-patching (by quqi99)

作者:张华  发表于:2016-02-27

版权声明:能够随意转载。转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

( http://blog.csdn.net/quqi99 )


GCC 4.6的mfentry特性支持使用ftrace在内核函数前加入一个勾子函数(可使用gcc -pg -mfentry test.c; objdump -d ./a.out命令确认),这个Kernel Live-pathing功能便是在内核未执行这个函数之前将函数地址替换掉。

Live-patching的数据结构见[1]. 打Live-patching的过程便是依据这个数据结构写模块动态插入,样例见[2]. kpatch是一个帮助动态地将一个patch生成这样的模块的工具。用法见[3].


[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/livepatch.h
[2] http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/plain/samples/livepatch/livepatch-sample.c
[3] http://chrisarges.net/2015/09/21/livepatch-on-ubuntu.html

原文地址:https://www.cnblogs.com/tlnshuju/p/7090098.html