On 2018-11-11, Masami Hiramatsu wrote: > > > > + addr = kretprobe_ret_addr(current, addr, stack_addr(regs)); > > > > > > But since kretprobe will be an event, which can kick the stackdump. > > > BTW, from kretprobe, regs->ip should always be the trampoline handler, > > > see arch/x86/kernel/kprobes/core.c:772 :-) > > > So it must be fixed always. > > > > Right, but kretprobe_ret_addr() is returning the *original* return > > address (and we need to do an (addr == kretprobe_trampoline)). The > > real problem is that stack_addr(regs) isn't the same as it is during > > kretprobe setup (but kretprobe_ret_addr() works everywhere else). > > I think stack_addr(regs) should be same when this is called from kretprobe > handler context. Otherwise, yes, it is not same, but in that case, regs->ip > is not kretprobe_trampoline too. I figured it out. It should be (regs->sp - 1) (just like it is inside the relevant unwinder function for ORC). I now have a prototype which works under the frame unwinder[*] -- however under ORC you can only see the top-most function (the unwinder doesn't see the other function calls). I'm playing with ORC hints with kretprobe_trampoline to try to improve things but it's still a bit screwy. [*]: However, I've noticed that the stack traces between the two traces no longer match. On kprobe you get function_name+1, but on kretprobe you get function_caller+foo. Obviously it's working but the return address results in slightly different stack traces. This means that stack trace aggregation between kprobe and kretprobe won't work anymore -- at least not like it did in my original patch. So I'm really not sure where to go from here. I can send around another patchset to illustrate the problem if you like (as well as show how the current unwinding code works). -- Aleksa Sarai Senior Software Engineer (Containers) SUSE Linux GmbH