Commit 50bf8080 authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

static_call: Fix the module key fixup

Provided the target address of a R_X86_64_PC32 relocation is aligned,
the low two bits should be invariant between the relative and absolute
value.

Turns out the address is not aligned and things go sideways, ensure we
transfer the bits in the absolute form when fixing up the key address.

Fixes: 73f44fe1 ("static_call: Allow module use without exposing static_call_key")
Reported-by: default avatarSteven Rostedt <rostedt@goodmis.org>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
Tested-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lkml.kernel.org/r/20210225220351.GE4746@worktop.programming.kicks-ass.net
parent a38fd874
...@@ -349,7 +349,8 @@ static int static_call_add_module(struct module *mod) ...@@ -349,7 +349,8 @@ static int static_call_add_module(struct module *mod)
struct static_call_site *site; struct static_call_site *site;
for (site = start; site != stop; site++) { for (site = start; site != stop; site++) {
unsigned long addr = (unsigned long)static_call_key(site); unsigned long s_key = (long)site->key + (long)&site->key;
unsigned long addr = s_key & ~STATIC_CALL_SITE_FLAGS;
unsigned long key; unsigned long key;
/* /*
...@@ -373,8 +374,8 @@ static int static_call_add_module(struct module *mod) ...@@ -373,8 +374,8 @@ static int static_call_add_module(struct module *mod)
return -EINVAL; return -EINVAL;
} }
site->key = (key - (long)&site->key) | key |= s_key & STATIC_CALL_SITE_FLAGS;
(site->key & STATIC_CALL_SITE_FLAGS); site->key = key - (long)&site->key;
} }
return __static_call_init(mod, start, stop); return __static_call_init(mod, start, stop);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment