Re: [PATCH bpf-next 3/3] selftests/bpf: Add uretprobe syscall test for regs changes

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

 



On Wed, Mar 27, 2024 at 3:21 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote:
>
> Adding test that creates uprobe consumer on uretprobe which changes some
> of the registers. Making sure the changed registers are propagated to the
> user space when the ureptobe syscall trampoline is used on x86_64.
>
> To be able to do this, adding support to bpf_testmod to create uprobe via
> new attribute file:
>   /sys/kernel/bpf_testmod_uprobe
>
> This file is expecting file offset and creates related uprobe on current
> process exe file and removes existing uprobe if offset is 0. The can be
> only single uprobe at any time.
>
> The uprobe has specific consumer that changes registers used in ureprobe
> syscall trampoline and which are later checked in the test.
>
> Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
> ---
>  .../selftests/bpf/bpf_testmod/bpf_testmod.c   | 119 +++++++++++++++++-
>  .../selftests/bpf/prog_tests/uprobe_syscall.c |  67 ++++++++++
>  2 files changed, 185 insertions(+), 1 deletion(-)
>

LGTM:

Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

[...]

>  BTF_KFUNCS_START(bpf_testmod_common_kfunc_ids)
>  BTF_ID_FLAGS(func, bpf_iter_testmod_seq_new, KF_ITER_NEW)
>  BTF_ID_FLAGS(func, bpf_iter_testmod_seq_next, KF_ITER_NEXT | KF_RET_NULL)
> @@ -650,7 +763,10 @@ static int bpf_testmod_init(void)
>                 return ret;
>         if (bpf_fentry_test1(0) < 0)
>                 return -EINVAL;
> -       return sysfs_create_bin_file(kernel_kobj, &bin_attr_bpf_testmod_file);
> +       ret = sysfs_create_bin_file(kernel_kobj, &bin_attr_bpf_testmod_file);
> +       if (ret < 0)
> +               return ret;
> +       return register_bpf_testmod_uprobe();

nit: keep using the same pattern to make adding more actions easier in
the future:

ret = register_bpf_testmod_uprobe();
if (ret < 0)
    return ret;
return 0;

>  }
>
>  static void bpf_testmod_exit(void)
> @@ -664,6 +780,7 @@ static void bpf_testmod_exit(void)
>                 msleep(20);
>
>         sysfs_remove_bin_file(kernel_kobj, &bin_attr_bpf_testmod_file);
> +       unregister_bpf_testmod_uprobe();
>  }
>

[...]





[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