mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
asm-generic: Refactor dereference_[kernel]_function_descriptor()
dereference_function_descriptor() and dereference_kernel_function_descriptor() are identical on the three architectures implementing them. Make them common and put them out-of-line in kernel/extable.c which is one of the users and has similar type of functions. Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Helge Deller <deller@gmx.de> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/449db09b2eba57f4ab05f80102a67d8675bc8bcd.1644928018.git.christophe.leroy@csgroup.eu
This commit is contained in:
parent
0dc690e4ef
commit
e1478d8eaf
6 changed files with 24 additions and 73 deletions
|
@ -3,6 +3,7 @@
|
|||
Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM.
|
||||
|
||||
*/
|
||||
#include <linux/elf.h>
|
||||
#include <linux/ftrace.h>
|
||||
#include <linux/memory.h>
|
||||
#include <linux/extable.h>
|
||||
|
@ -132,12 +133,32 @@ out:
|
|||
}
|
||||
|
||||
/*
|
||||
* On some architectures (PPC64, IA64) function pointers
|
||||
* On some architectures (PPC64, IA64, PARISC) function pointers
|
||||
* are actually only tokens to some data that then holds the
|
||||
* real function address. As a result, to find if a function
|
||||
* pointer is part of the kernel text, we need to do some
|
||||
* special dereferencing first.
|
||||
*/
|
||||
#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS
|
||||
void *dereference_function_descriptor(void *ptr)
|
||||
{
|
||||
func_desc_t *desc = ptr;
|
||||
void *p;
|
||||
|
||||
if (!get_kernel_nofault(p, (void *)&desc->addr))
|
||||
ptr = p;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *dereference_kernel_function_descriptor(void *ptr)
|
||||
{
|
||||
if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd)
|
||||
return ptr;
|
||||
|
||||
return dereference_function_descriptor(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
int func_ptr_is_kernel_text(void *ptr)
|
||||
{
|
||||
unsigned long addr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue