提交 9e667624 编写于 作者: P Peter Zijlstra 提交者: Ingo Molnar

jump_label: Fix jump_label_text_reserved() vs __init

It turns out that jump_label_text_reserved() was reporting __init text
as being reserved past the time when the __init text was freed and
re-used.

For a long time, this resulted in, at worst, not being able to kprobe
text that happened to land at the re-used address. However a recent
commit e7bf1ba9 ("jump_label, x86: Emit short JMP") made it a
fatal mistake because it now needs to read the instruction in order to
determine the conflict -- an instruction that's no longer there.

Fixes: 4c3ef6d7 ("jump label: Add jump_label_text_reserved() to reserve jump points")
Reported-by: Nkernel test robot <oliver.sang@intel.com>
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: NIngo Molnar <mingo@kernel.org>
Reviewed-by: NMasami Hiramatsu <mhiramat@kernel.org>
Link: https://lore.kernel.org/r/20210628113045.045141693@infradead.org
上级 4840ce22
...@@ -316,14 +316,16 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end) ...@@ -316,14 +316,16 @@ static int addr_conflict(struct jump_entry *entry, void *start, void *end)
} }
static int __jump_label_text_reserved(struct jump_entry *iter_start, static int __jump_label_text_reserved(struct jump_entry *iter_start,
struct jump_entry *iter_stop, void *start, void *end) struct jump_entry *iter_stop, void *start, void *end, bool init)
{ {
struct jump_entry *iter; struct jump_entry *iter;
iter = iter_start; iter = iter_start;
while (iter < iter_stop) { while (iter < iter_stop) {
if (addr_conflict(iter, start, end)) if (init || !jump_entry_is_init(iter)) {
return 1; if (addr_conflict(iter, start, end))
return 1;
}
iter++; iter++;
} }
...@@ -562,7 +564,7 @@ static int __jump_label_mod_text_reserved(void *start, void *end) ...@@ -562,7 +564,7 @@ static int __jump_label_mod_text_reserved(void *start, void *end)
ret = __jump_label_text_reserved(mod->jump_entries, ret = __jump_label_text_reserved(mod->jump_entries,
mod->jump_entries + mod->num_jump_entries, mod->jump_entries + mod->num_jump_entries,
start, end); start, end, mod->state == MODULE_STATE_COMING);
module_put(mod); module_put(mod);
...@@ -788,8 +790,9 @@ early_initcall(jump_label_init_module); ...@@ -788,8 +790,9 @@ early_initcall(jump_label_init_module);
*/ */
int jump_label_text_reserved(void *start, void *end) int jump_label_text_reserved(void *start, void *end)
{ {
bool init = system_state < SYSTEM_RUNNING;
int ret = __jump_label_text_reserved(__start___jump_table, int ret = __jump_label_text_reserved(__start___jump_table,
__stop___jump_table, start, end); __stop___jump_table, start, end, init);
if (ret) if (ret)
return ret; return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册