Patch "arm: kprobes: Fix the return address of multiple kretprobes" has been added to the 4.4-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
arm: kprobes: Fix the return address of multiple kretprobes
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm-kprobes-fix-the-return-address-of-multiple-kretprobes.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From foo@baz Thu Dec 21 10:35:49 CET 2017
From: Masami Hiramatsu <[email protected]>
Date: Tue, 14 Feb 2017 00:05:59 +0900
Subject: arm: kprobes: Fix the return address of multiple kretprobes
From: Masami Hiramatsu <[email protected]>
[ Upstream commit 06553175f585b52509c7df37d6f4a50aacb7b211 ]
This is arm port of commit 737480a0d525 ("kprobes/x86:
Fix the return address of multiple kretprobes").
Fix the return address of subsequent kretprobes when multiple kretprobes are set on the same function.
For example:
# cd /sys/kernel/debug/tracing # echo "r:event1 sys_symlink" > kprobe_events # echo "r:event2 sys_symlink" >> kprobe_events # echo 1 > events/kprobes/enable # ln -s /tmp/foo /tmp/bar
(without this patch)
# cat trace | grep -v ^#
ln-82 [000] dn.2 68.446525: event1: (kretprobe_trampoline+0x0/0x18 <- SyS_symlink)
ln-82 [000] dn.2 68.447831: event2: (ret_fast_syscall+0x0/0x1c <- SyS_symlink)(with this patch)
# cat trace | grep -v ^#
ln-81 [000] dn.1 39.463469: event1: (ret_fast_syscall+0x0/0x1c <- SyS_symlink)
ln-81 [000] dn.1 39.464701: event2: (ret_fast_syscall+0x0/0x1c <- SyS_symlink)--- arch/arm/probes/kprobes/core.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-)
arch/arm/probes/kprobes/core.c +22 -2
@@ -433,6 +433,7 @@ static __used __kprobes void *trampolinestruct hlist_node *tmp;unsigned long flags, orig_ret_address =0 ;unsigned long trampoline_address = (unsigned long )&kretprobe_trampoline; +kprobe_opcode_t *correct_ret_addr =NULL ;INIT_HLIST_HEAD (&empty_rp);kretprobe_hash_lock (current, &head, &flags);
@@ -455,14 +456,34 @@ static __used __kprobes void *trampoline/* another task is sharing our hash bucket */ continue ; + orig_ret_address = (unsigned long )ri->ret_addr; + +if (orig_ret_address != trampoline_address) +/* +* This is the real return address. Any other +* instances associated with this task are for +* other calls deeper on the call stack +*/ +break ; + } + +kretprobe_assert (ri, orig_ret_address, trampoline_address); + + correct_ret_addr = ri->ret_addr; +hlist_for_each_entry_safe (ri, tmp, head, hlist) { +if (ri->task != current) +/* another task is sharing our hash bucket */ +continue ; + + orig_ret_address = (unsigned long )ri->ret_addr;if (ri->rp && ri->rp->handler) {__this_cpu_write (current_kprobe, &ri->rp->kp);get_kprobe_ctlblk ()->kprobe_status =KPROBE_HIT_ACTIVE ; + ri->ret_addr = correct_ret_addr; ri->rp->handler (ri, regs);__this_cpu_write (current_kprobe,NULL ); } - orig_ret_address = (unsigned long )ri->ret_addr;recycle_rp_inst (ri, &empty_rp);if (orig_ret_address != trampoline_address)
@@ -474,7 +495,6 @@ static __used __kprobes void *trampolinebreak ; } -kretprobe_assert (ri, orig_ret_address, trampoline_address);kretprobe_hash_unlock (current, &flags);hlist_for_each_entry_safe (ri, tmp, &empty_rp, hlist) {
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/arm-kprobes-fix-the-return-address-of-multiple-kretprobes.patch