Re: [PATCHv4 bpf-next 5/6] bpf: Return value in kprobe get_func_ip only for entry address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Sep 25, 2022 at 07:42:48AM +0200, Martynas Pumputis wrote:
> On 9/22/22 23:03, Jiri Olsa wrote:
> > Changing return value of kprobe's version of bpf_get_func_ip
> > to return zero if the attach address is not on the function's
> > entry point.
> > 
> > For kprobes attached in the middle of the function we can't easily
> > get to the function address especially now with the CONFIG_X86_KERNEL_IBT
> > support.
> > 
> > If user cares about current IP for kprobes attached within the
> > function body, they can get it with PT_REGS_IP(ctx).
> > 
> > Suggested-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> 
> Tested the patches with "pwru --filter-func='.*skb.*'
> --filter-dst-ip=1.1.1.1" from [1] - the symbol name resolution works,
> thanks!
> 
> Without your patches:
> 
>                SKB    CPU          PROCESS                     FUNC
> 0xffff8989c159b4e8      0           [curl]       0xffffffffbbb06164
> 0xffff8989c223f000      0           [curl]       0xffffffffbbb07534
> 0xffff8989c223f000      0           [curl]       0xffffffffbbb04934
> 0xffff8989c223f000      0           [curl]         skb_release_data
> 0xffff8989c223f000      0           [curl]             kfree_skbmem
> 0xffff8989c159b4e8      0           [curl]       0xffffffffbbb00db4
> [..]
> 
> With patches:
> 
>                SKB    CPU          PROCESS                     FUNC
> 0xffffa4564159b4e8      0           [curl]   validate_xmit_skb_list
> 0xffffa4564159b4e8      0           [curl]       netif_skb_features
> 0xffffa4564159b4e8      0           [curl]     skb_network_protocol
> 0xffffa4564159b4e8      0           [curl]  skb_csum_hwoffload_help
> 0xffffa4564159b4e8      0           [curl]        skb_checksum_help
> 0xffffa4564159b4e8      0           [curl]      skb_ensure_writable
> 0xffffa4564159b4e8      0           [curl]             skb_to_sgvec
> [..]
> 
> [1]: https://github.com/cilium/pwru/tree/test-ibt-kernel-fix
> 
> Acked-by: Martynas Pumputis <m@xxxxxxxxx>

awesome, thanks

jirka

> 
> > ---
> >   kernel/trace/bpf_trace.c                             | 5 ++++-
> >   tools/testing/selftests/bpf/progs/get_func_ip_test.c | 4 ++--
> >   2 files changed, 6 insertions(+), 3 deletions(-)
> 
> [..]



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux