Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 73f44fe19d35 ("static_call: Allow module use without exposing static_call_key")
Reported-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Link: https://lkml.kernel.org/r/20210225220351.GE4746@worktop.programming.kicks-ass.net

authored by

Peter Zijlstra and committed by
Ingo Molnar
50bf8080 a38fd874

+4 -3
+4 -3
kernel/static_call.c
··· 349 349 struct static_call_site *site; 350 350 351 351 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; 353 354 unsigned long key; 354 355 355 356 /* ··· 374 373 return -EINVAL; 375 374 } 376 375 377 - site->key = (key - (long)&site->key) | 378 - (site->key & STATIC_CALL_SITE_FLAGS); 376 + key |= s_key & STATIC_CALL_SITE_FLAGS; 377 + site->key = key - (long)&site->key; 379 378 } 380 379 381 380 return __static_call_init(mod, start, stop);