Skip to content

Commit 50bf808

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
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: 73f44fe ("static_call: Allow module use without exposing static_call_key") Reported-by: Steven Rostedt <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Tested-by: Steven Rostedt (VMware) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent a38fd87 commit 50bf808

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

kernel/static_call.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@ static int static_call_add_module(struct module *mod)
349349
struct static_call_site *site;
350350

351351
for (site = start; site != stop; site++) {
352-
unsigned long addr = (unsigned long)static_call_key(site);
352+
unsigned long s_key = (long)site->key + (long)&site->key;
353+
unsigned long addr = s_key & ~STATIC_CALL_SITE_FLAGS;
353354
unsigned long key;
354355

355356
/*
@@ -373,8 +374,8 @@ static int static_call_add_module(struct module *mod)
373374
return -EINVAL;
374375
}
375376

376-
site->key = (key - (long)&site->key) |
377-
(site->key & STATIC_CALL_SITE_FLAGS);
377+
key |= s_key & STATIC_CALL_SITE_FLAGS;
378+
site->key = key - (long)&site->key;
378379
}
379380

380381
return __static_call_init(mod, start, stop);

0 commit comments

Comments
 (0)