Merge a topic branch we are maintaining with some cross-architecture changes to function descriptor handling and their use in LKDTM. From Christophe's cover letter: Fix LKDTM for PPC64/IA64/PARISC PPC64/IA64/PARISC have function descriptors. LKDTM doesn't work on those three architectures because LKDTM messes up function descriptors with functions. This series does some cleanup in the three architectures and refactors function descriptors so that it can then easily use it in a generic way in LKDTM.
Showing the changes to kernel (1 of 25 files). Show all
Unified · Split
| @@ -3,6 +3,7 @@ · 2 unmodified lines | ||
| 3 | 3 | Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM. |
| 4 | 4 | |
| 5 | 5 | */ |
| 6 | +#include <linux/elf.h> | |
| 6 | 7 | #include <linux/ftrace.h> |
| 7 | 8 | #include <linux/memory.h> |
| 8 | 9 | #include <linux/extable.h> |
| @@ -132,12 +133,33 @@ out: · 123 unmodified lines | ||
| 132 | 133 | } |
| 133 | 134 | |
| 134 | 135 | /* |
| 135 | − * On some architectures (PPC64, IA64) function pointers | |
| 136 | + * On some architectures (PPC64, IA64, PARISC) function pointers | |
| 136 | 137 | * are actually only tokens to some data that then holds the |
| 137 | 138 | * real function address. As a result, to find if a function |
| 138 | 139 | * pointer is part of the kernel text, we need to do some |
| 139 | 140 | * special dereferencing first. |
| 140 | 141 | */ |
| 142 | +#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS | |
| 143 | +void *dereference_function_descriptor(void *ptr) | |
| 144 | +{ | |
| 145 | + func_desc_t *desc = ptr; | |
| 146 | + void *p; | |
| 147 | + | |
| 148 | + if (!get_kernel_nofault(p, (void *)&desc->addr)) | |
| 149 | + ptr = p; | |
| 150 | + return ptr; | |
| 151 | +} | |
| 152 | +EXPORT_SYMBOL_GPL(dereference_function_descriptor); | |
| 153 | + | |
| 154 | +void *dereference_kernel_function_descriptor(void *ptr) | |
| 155 | +{ | |
| 156 | + if (ptr < (void *)__start_opd || ptr >= (void *)__end_opd) | |
| 157 | + return ptr; | |
| 158 | + | |
| 159 | + return dereference_function_descriptor(ptr); | |
| 160 | +} | |
| 161 | +#endif | |
| 162 | + | |
| 141 | 163 | int func_ptr_is_kernel_text(void *ptr) |
| 142 | 164 | { |
| 143 | 165 | unsigned long addr; |