提交 9725a52f 编写于 作者: P Peter Zijlstra 提交者: Zheng Zengkai

static_call: Fix static_call_text_reserved() vs __init

stable inclusion
from stable-5.10.52
commit 53c5c2496fc9953ca1e67d3435f7d3f111da86d3
bugzilla: 175542 https://gitee.com/openeuler/kernel/issues/I4DTKU

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=53c5c2496fc9953ca1e67d3435f7d3f111da86d3

--------------------------------

[ Upstream commit 2bee6d16 ]

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

This is mostly harmless and will at worst result in refusing a kprobe.

Fixes: 6333e8f7 ("static_call: Avoid kprobes on inline static_call()s")
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.106211657@infradead.orgSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Acked-by: NWeilong Chen <chenweilong@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 4a332773
...@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end) ...@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)
static int __static_call_text_reserved(struct static_call_site *iter_start, static int __static_call_text_reserved(struct static_call_site *iter_start,
struct static_call_site *iter_stop, struct static_call_site *iter_stop,
void *start, void *end) void *start, void *end, bool init)
{ {
struct static_call_site *iter = iter_start; struct static_call_site *iter = iter_start;
while (iter < iter_stop) { while (iter < iter_stop) {
if (addr_conflict(iter, start, end)) if (init || !static_call_is_init(iter)) {
return 1; if (addr_conflict(iter, start, end))
return 1;
}
iter++; iter++;
} }
...@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end) ...@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end)
ret = __static_call_text_reserved(mod->static_call_sites, ret = __static_call_text_reserved(mod->static_call_sites,
mod->static_call_sites + mod->num_static_call_sites, mod->static_call_sites + mod->num_static_call_sites,
start, end); start, end, mod->state == MODULE_STATE_COMING);
module_put(mod); module_put(mod);
...@@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end) ...@@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end)
int static_call_text_reserved(void *start, void *end) int static_call_text_reserved(void *start, void *end)
{ {
bool init = system_state < SYSTEM_RUNNING;
int ret = __static_call_text_reserved(__start_static_call_sites, int ret = __static_call_text_reserved(__start_static_call_sites,
__stop_static_call_sites, start, end); __stop_static_call_sites, 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.
先完成此消息的编辑!
想要评论请 注册