Skip to content

Commit 2bee6d1

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
static_call: Fix static_call_text_reserved() vs __init
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: 6333e8f ("static_call: Avoid kprobes on inline static_call()s") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Masami Hiramatsu <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9e66762 commit 2bee6d1

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

kernel/static_call.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,15 @@ static int addr_conflict(struct static_call_site *site, void *start, void *end)
292292

293293
static int __static_call_text_reserved(struct static_call_site *iter_start,
294294
struct static_call_site *iter_stop,
295-
void *start, void *end)
295+
void *start, void *end, bool init)
296296
{
297297
struct static_call_site *iter = iter_start;
298298

299299
while (iter < iter_stop) {
300-
if (addr_conflict(iter, start, end))
301-
return 1;
300+
if (init || !static_call_is_init(iter)) {
301+
if (addr_conflict(iter, start, end))
302+
return 1;
303+
}
302304
iter++;
303305
}
304306

@@ -324,7 +326,7 @@ static int __static_call_mod_text_reserved(void *start, void *end)
324326

325327
ret = __static_call_text_reserved(mod->static_call_sites,
326328
mod->static_call_sites + mod->num_static_call_sites,
327-
start, end);
329+
start, end, mod->state == MODULE_STATE_COMING);
328330

329331
module_put(mod);
330332

@@ -459,8 +461,9 @@ static inline int __static_call_mod_text_reserved(void *start, void *end)
459461

460462
int static_call_text_reserved(void *start, void *end)
461463
{
464+
bool init = system_state < SYSTEM_RUNNING;
462465
int ret = __static_call_text_reserved(__start_static_call_sites,
463-
__stop_static_call_sites, start, end);
466+
__stop_static_call_sites, start, end, init);
464467

465468
if (ret)
466469
return ret;

0 commit comments

Comments
 (0)