mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 10:41:38 -04:00
jprobes: make jprobes a little safer for users
I realise jprobes are a razor-blades-included type of interface, but that
doesn't mean we can't try and make them safer to use. This guy I know once
wrote code like this:
struct jprobe jp = { .kp.symbol_name = "foo", .entry = "jprobe_foo" };
And then his kernel exploded. Oops.
This patch adds an arch hook, arch_deref_entry_point() (I don't like it
either) which takes the void * in a struct jprobe, and gives back the text
address that it represents.
We can then use that in register_jprobe() to check that the entry point we're
passed is actually in the kernel text, rather than just some random value.
Signed-off-by: Michael Ellerman <[email protected]>
Cc: Prasanna S Panchamukhi <[email protected]>
Acked-by: Ananth N Mavinakayanahalli <[email protected]>
Cc: Anil S Keshavamurthy <[email protected]>
Cc: David S. Miller <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
9e367d8592
commit
3d7e33825d
4 changed files with 24 additions and 4 deletions
|
|
@ -675,9 +675,18 @@ static struct notifier_block kprobe_exceptions_nb = {
|
|||
.priority = 0x7fffffff /* we need to be notified first */
|
||||
};
|
||||
|
||||
unsigned long __weak arch_deref_entry_point(void *entry)
|
||||
{
|
||||
return (unsigned long)entry;
|
||||
}
|
||||
|
||||
int __kprobes register_jprobe(struct jprobe *jp)
|
||||
{
|
||||
unsigned long addr = arch_deref_entry_point(jp->entry);
|
||||
|
||||
if (!kernel_text_address(addr))
|
||||
return -EINVAL;
|
||||
|
||||
/* Todo: Verify probepoint is a function entry point */
|
||||
jp->kp.pre_handler = setjmp_pre_handler;
|
||||
jp->kp.break_handler = longjmp_break_handler;
|
||||
|
|
|
|||
Loading…
Reference in a new issue