Compile-time stack validation
In order to get their code upstream, they must first invest considerable effort into
fixing a related subsystem. Live patching is exactly a case in point.
Live patch’s dilemma
Consistecy Model
“Consistecy model” remained unsettled, even ther core code had been merged.
Ensuring that a patch is applied to a live kernel if it is safe to do so;
- that job includes checking to be sure that the affected functions are not
executing at the time the patch is applied. - Don’t cause crash during patching.
Atempts
- Freeze all:
One way of ensuring that a given function is not executing is to freeze all processes
on the system, then examine the call stack of each to see which functions are active
all the time. – used by kPatch and kGraft.
But, strong opposition came for a simple reason: the information in the kernel’s
call stack is often not reliable.
for example: assembly code that does not set up proper stack frames
At the time, 100% reliable stack traces were not widely seen as an attainable goal. It is certainly possible to fix up all of the assembly code that does not set up proper stack frames (assuming it could all be found), but, since nothing in the kernel’s normal operation depends on good call-stack information, there was nothing preventing things from breaking again at any time. In the absence of some sort of ongoing assurance that the kernel’s call stack will always remain valid, it is hard to be confident that a live-patching system won’t do the wrong thing.
Conclusion
In the absence of some sort of ongoing assurance that the kernel’s call stack
will always remain valid, it is hard to be confident that a live-patching system won’t do the wrong thing.
- Assembly code calls another function without setting up new stack frame.
The validation tool checks to make sure that function calls are surrounded by the appropriate frame-maintenance code.
There are currently assembly macros to do this work, but they are unused; Josh’s patch renames them to FRAME_BEGIN and FRAME_END and puts them into use.
Versions of these macros for inline assembly in C code have also been added; they can be found in <asm/frame.h>. - Dynmamic jumps
for the most part, they are only allowed as part of a C switch statement.
for “siling calls”, where the end of one function jumps to the beginning of another and the frame pointer hasn’t changed.
Validating the call stack
Josh Poimboeuf find a wat to make the call stack valid at all times and keep it
that way, named “compile-time stack metadata validation”.
This work adds a new tool (called stacktool)
that checks the entire kernel as part of the build process to be sure that all
code obeys the rules for maintaining the call stack.
Every function in assembly code must be marked aas a callable function(ELF function type)

本文讨论了实时内核补丁的困境,特别是关于一致性模型的不确定性。在确保补丁安全应用到运行内核的过程中,需要验证受影响函数在补丁应用时是否执行。提出了冻结所有进程以检查调用堆栈的方法,但由于内核调用堆栈信息的不可靠性,这种方法受到质疑。作者提出了一种名为'编译时栈元数据验证'的方法,通过新的工具stacktool在构建过程中检查整个内核,确保所有代码都遵循维护调用栈的规则,每个汇编函数都标记为可调用函数,从而增强对实时补丁系统的信心。
3182

被折叠的 条评论
为什么被折叠?



