Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: demonstration of uprobe/uretprobe corrupted stack traces
Hi Masami, We've got reports about partially corrupt stack traces when being captured from uretprobes. Trying the simplest repro seems to confirm that something is not quite right here. I'll try to debug it a bit more this week, but I was hoping for you to take a look as well, if you get a chance. Simple repro built on top of BPF selftests. $ sudo ./test_progs -a uprobe_autoattach -v ... FN ADDR 0x55fde0 - 0x55fdef UPROBE SZ 40 (CNT 5) URETPROBE SZ 40 (CNT 5) UPROBE 0x55fde0 URETPROBE 0x55ffd4 UPROBE 0x584653 URETPROBE 0x584653 UPROBE 0x585cc9 URETPROBE 0x585cc9 UPROBE 0x7fa9a31eaca3 URETPROBE 0x7fa9a31eaca3 UPROBE 0x5541f689495641d7 URETPROBE 0x5541f689495641d7 ... #203 uprobe_autoattach:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED There seem to be two distinct problems. 1. Last two entries for both uprobe and uretprobe stacks are not user-space addressed (0x7fa9a31eaca3) and the very last one doesn't even look like a valid address (0x5541f689495641d7). 2. Looking at first entry for UPROBE vs URETPROBE, you can see that uprobe one's is correct and points exactly to the beginning of autoattach_trigger_func (0x55fde0) as expected, but uretprobe entry (0x55ffd4) is way out of autoattach_trigger_func (which is just 15 bytes long and ends at 0x55fdef). Using addr2line it shows that it points to: 0x000000000055ffd4: test_uprobe_autoattach at /data/users/andriin/linux/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c:33 Which is a valid function and location to which autoattach_trigger_func() should return (see objdump snippet below), but from uretprobe I'd imagine that we are going to get address within traced user function (that is 0x55fde0 - 0x55fdef range), not the return address in a parent function. 55ffc4: 89 83 3c 08 00 00 mov %eax,0x83c(%rbx) 55ffca: 8b 45 e8 mov -0x18(%rbp),%eax 55ffcd: 89 c7 mov %eax,%edi 55ffcf: e8 0c fe ff ff call 55fde0 <autoattach_trigger_func> --> 55ffd4: 89 45 a8 mov %eax,-0x58(%rbp) 55ffd7: ba ef fd 55 00 mov $0x55fdef,%edx Both issues above seem unexpected, can you please see if I have some wrong assumptions here? Thanks in advance for taking a look! Cc: Jiri Olsa <jolsa@kernel.org> Cc: Riham Selim <rihams@fb.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
- Loading branch information