Skip to content

Commit 83e840c

Browse files
rnavmpe
authored andcommitted
powerpc64/elfv1: Only dereference function descriptor for non-text symbols
Currently, we assume that the function pointer we receive in ppc_function_entry() points to a function descriptor. However, this is not always the case. In particular, assembly symbols without the right annotation do not have an associated function descriptor. Some of these symbols are added to the kprobe blacklist using _ASM_NOKPROBE_SYMBOL(). When such addresses are subsequently processed through arch_deref_entry_point() in populate_kprobe_blacklist(), we see the below errors during bootup: [ 0.663963] Failed to find blacklist at 7d9b02a648029b6c [ 0.663970] Failed to find blacklist at a14d03d0394a0001 [ 0.663972] Failed to find blacklist at 7d5302a6f94d0388 [ 0.663973] Failed to find blacklist at 48027d11e8610178 [ 0.663974] Failed to find blacklist at f8010070f8410080 [ 0.663976] Failed to find blacklist at 386100704801f89d [ 0.663977] Failed to find blacklist at 7d5302a6f94d00b0 Fix this by checking if the function pointer we receive in ppc_function_entry() already points to kernel text. If so, we just return it as is. If not, we assume that this is a function descriptor and proceed to dereference it. Suggested-by: Nicholas Piggin <[email protected]> Reviewed-by: Nicholas Piggin <[email protected]> Signed-off-by: Naveen N. Rao <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 3ced8d7 commit 83e840c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

arch/powerpc/include/asm/code-patching.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,16 @@ static inline unsigned long ppc_function_entry(void *func)
8383
* On PPC64 ABIv1 the function pointer actually points to the
8484
* function's descriptor. The first entry in the descriptor is the
8585
* address of the function text.
86+
*
87+
* However, we may also receive pointer to an assembly symbol. To
88+
* detect that, we first check if the function pointer we receive
89+
* already points to kernel/module text and we only dereference it
90+
* if it doesn't.
8691
*/
87-
return ((func_descr_t *)func)->entry;
92+
if (kernel_text_address((unsigned long)func))
93+
return (unsigned long)func;
94+
else
95+
return ((func_descr_t *)func)->entry;
8896
#else
8997
return (unsigned long)func;
9098
#endif

0 commit comments

Comments
 (0)