Re: [PATCH bpf-next 4/5] selftests/bpf: Disable kprobe attach test with offset for CONFIG_X86_KERNEL_IBT

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

 



On Fri, Jul 29, 2022 at 03:15:55PM -0700, Andrii Nakryiko wrote:
> On Sun, Jul 24, 2022 at 2:22 PM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
> >
> > Attach like 'kprobe/bpf_fentry_test6+0x5' will fail to attach
> > when CONFIG_X86_KERNEL_IBT option is enabled because of the
> > endbr instruction at the function entry.
> >
> > We would need to do manual attach with offset calculation based
> > on the CONFIG_X86_KERNEL_IBT option, which does not seem worth
> > the effort to me.
> >
> > Disabling these test when CONFIG_X86_KERNEL_IBT is enabled.
> >
> > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> > ---
> >  .../bpf/prog_tests/get_func_ip_test.c         | 25 +++++++++++++++----
> >  1 file changed, 20 insertions(+), 5 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c b/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
> > index 938dbd4d7c2f..cb0b78fb29df 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/get_func_ip_test.c
> > @@ -2,6 +2,24 @@
> >  #include <test_progs.h>
> >  #include "get_func_ip_test.skel.h"
> >
> > +/* assume IBT is enabled when kernel configs are not available */
> > +#ifdef HAVE_GENHDR
> > +# include "autoconf.h"
> > +#else
> > +#  define CONFIG_X86_KERNEL_IBT 1
> > +#endif
> 
> this autoconf.h business is something I'd rather avoid, it would be
> great to be able to use libbpf's __kconfig support to detect
> CONFIG_X86_KERNEL_IBT instead? One way would be to mark test6/test7 as
> non-auto-loadable (SEC("?...")). Load only test1-tes5, run tests, in

aah so that's what the '?' prefix is for :))

> one of BPF programs propagate __kconfig CONFIG_X86_KERNEL_IBT to
> user-space through a global variable. Attach skeleton, trigger
> everything, remember whether IBT is enabled or not.
> 
> If it is defined, load skeleton again, but now enable test6 and test7
> and manually attach them through bpf_program__attach_kprobe()
> specifying offset as +5 or +9, depending on IBT. It's certainly a bit
> more code, but we'll actually test IBT stuff properly.
> 
> WDYT?

right, seems doable.. also I wonder how hard would it be to have some
generic support for that, maybe there are other users..  I'll check

thanks,
jirka



[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