Re: [PATCH bpf-next v6 09/14] selftests/bpf: Make uprobe tests use different attach functions.

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

 



On Fri, Oct 8, 2021 at 3:47 PM sunyucong@xxxxxxxxx <sunyucong@xxxxxxxxx> wrote:
>
> On Fri, Oct 8, 2021 at 3:27 PM Andrii Nakryiko
> <andrii.nakryiko@xxxxxxxxx> wrote:
> >
> > On Wed, Oct 6, 2021 at 11:56 AM Yucong Sun <fallentree@xxxxxx> wrote:
> > >
> > > From: Yucong Sun <sunyucong@xxxxxxxxx>
> > >
> > > Using same address on different processes of the same binary often fail
> > > with EINVAL, this patch make these tests use distinct methods, so they
> > > can run in parallel.
> > >
> > > Signed-off-by: Yucong Sun <sunyucong@xxxxxxxxx>
> > > ---
> > >  tools/testing/selftests/bpf/prog_tests/attach_probe.c | 8 ++++++--
> > >  tools/testing/selftests/bpf/prog_tests/bpf_cookie.c   | 8 ++++++--
> > >  tools/testing/selftests/bpf/prog_tests/task_pt_regs.c | 8 ++++++--
> > >  3 files changed, 18 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> > > index 6c511dcd1465..eff36ba9c148 100644
> > > --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> > > +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c
> > > @@ -5,6 +5,10 @@
> > >  /* this is how USDT semaphore is actually defined, except volatile modifier */
> > >  volatile unsigned short uprobe_ref_ctr __attribute__((unused)) __attribute((section(".probes")));
> > >
> > > +static int method() {
> >
> > wrong style: { should be on separate line
> >
> > > +       return get_base_addr();
> >
> > there is nothing special about get_base_addr(), except that it's a
> > global function in a different file and won't be inlined, while this
> > method() approach has no such guarantee
> >
> > I've dropped this patch for now.
> >
> > But I'm surprised that attaching to the same uprobe few times doesn't
> > work. Song, is there anything in kernel that could cause this?
>
>
> libbpf: uprobe perf_event_open() failed: Invalid argument
> libbpf: prog 'handle_uprobe': failed to create uprobe
> '/proc/self/exe:0x144d59' perf event: Invalid argument
> uprobe_subtest:FAIL:link1 unexpected error: -22
>
> The problem only happens when several different processes of the same
> binary are trying to attach uprobe on the same function. I am guessing
> it is due to address space randomization ?

nope, we don't use address space randomization, it's the
ref_ctr_offset (normally used for USDT semaphore)

>
> I traced through the code and the EINVAL is returned right after this warning
>
> [    1.375901] ref_ctr_offset mismatch. inode: 0x55a0 offset: 0x144d59
> ref_ctr_offset(old): 0x554a00 ref_ctr_offset(new): 0x0

ah, ref_ctr_offset is probably enforced by the kernel to be the same
across all uprobes. attach_probe is the only one that's testing
ref_ctr_offset, so it should be enough to modify only that one, just
make sure you are using a non-inlined function for this.

>
>
> This could be easily be reproduced by    ./test_progs -t
> attach_probe,bpf_cookie,test_pt_regs -j
>
> >
> >
> > > +}
> > > +

[...]



[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