History

Merge branch 'topic/func-desc-lkdtm' into next

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.

Michael Ellerman committed 4 years ago

Commit 4bc06c52 parents 8219d31 5e5a6c525 files · +155 −144Browse files

Showing the changes to kernel (1 of 25 files). Show all

Unified · Split

kernel/extable.c+23−1
@@ -3,6 +3,7 @@ · 2 unmodified lines
3 Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM.3 Copyright (C) 2001 Rusty Russell, 2002 Rusty Russell IBM.
4 4
5*/5*/
6#include <linux/elf.h>
6#include <linux/ftrace.h>7#include <linux/ftrace.h>
7#include <linux/memory.h>8#include <linux/memory.h>
8#include <linux/extable.h>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 pointers136 * On some architectures (PPC64, IA64, PARISC) function pointers
136 * are actually only tokens to some data that then holds the137 * are actually only tokens to some data that then holds the
137 * real function address. As a result, to find if a function138 * real function address. As a result, to find if a function
138 * pointer is part of the kernel text, we need to do some139 * pointer is part of the kernel text, we need to do some
139 * special dereferencing first.140 * special dereferencing first.
140 */141 */
142#ifdef CONFIG_HAVE_FUNCTION_DESCRIPTORS
143void *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}
152EXPORT_SYMBOL_GPL(dereference_function_descriptor);
153
154void *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
141int func_ptr_is_kernel_text(void *ptr)163int func_ptr_is_kernel_text(void *ptr)
142{164{
143 unsigned long addr;165 unsigned long addr;