lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 19 Aug 2020 12:29:49 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Yonghong Song <yhs@...com>
Cc:     Andrii Nakryiko <andriin@...com>, bpf <bpf@...r.kernel.org>,
        Networking <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...com>,
        Daniel Borkmann <daniel@...earbox.net>,
        Kernel Team <kernel-team@...com>
Subject: Re: [PATCH v2 bpf-next 2/5] selftests/bpf: test TYPE_EXISTS and
 TYPE_SIZE CO-RE relocations

On Wed, Aug 19, 2020 at 9:31 AM Yonghong Song <yhs@...com> wrote:
>
>
>
> On 8/18/20 10:28 PM, Andrii Nakryiko wrote:
> > Add selftests for TYPE_EXISTS and TYPE_SIZE relocations, testing correctness
> > of relocations and handling of type compatiblity/incompatibility.
> >
> > If __builtin_preserve_type_info() is not supported by compiler, skip tests.
> >
> > Signed-off-by: Andrii Nakryiko <andriin@...com>
> > ---
> >   .../selftests/bpf/prog_tests/core_reloc.c     | 125 +++++++++--
> >   .../bpf/progs/btf__core_reloc_type_based.c    |   3 +
> >   ...btf__core_reloc_type_based___all_missing.c |   3 +
> >   .../btf__core_reloc_type_based___diff_sz.c    |   3 +
> >   ...f__core_reloc_type_based___fn_wrong_args.c |   3 +
> >   .../btf__core_reloc_type_based___incompat.c   |   3 +
> >   .../selftests/bpf/progs/core_reloc_types.h    | 203 +++++++++++++++++-
> >   .../bpf/progs/test_core_reloc_kernel.c        |   2 +
> >   .../bpf/progs/test_core_reloc_type_based.c    | 125 +++++++++++
> >   9 files changed, 448 insertions(+), 22 deletions(-)
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___all_missing.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___diff_sz.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___fn_wrong_args.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/btf__core_reloc_type_based___incompat.c
> >   create mode 100644 tools/testing/selftests/bpf/progs/test_core_reloc_type_based.c
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> > index 4d650e99be28..b775ce0ede41 100644
> > --- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> > +++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c
> > @@ -177,14 +177,13 @@
> >       .fails = true,                                                  \
> >   }
> >
> [...]
> > +/* func_proto with incompatible signature */
> > +typedef void (*func_proto_typedef___fn_wrong_ret1)(long);
> > +typedef int * (*func_proto_typedef___fn_wrong_ret2)(long);
> > +typedef struct { int x; } int_struct_typedef;
> > +typedef int_struct_typedef (*func_proto_typedef___fn_wrong_ret3)(long);
> > +typedef int (*func_proto_typedef___fn_wrong_arg)(void *);
> > +typedef int (*func_proto_typedef___fn_wrong_arg_cnt1)(long, long);
> > +typedef int (*func_proto_typedef___fn_wrong_arg_cnt2)(void);
> > +
> > +struct core_reloc_type_based___fn_wrong_args {
> > +     /* one valid type to make sure relos still work */
> > +     struct a_struct f1;
> > +     func_proto_typedef___fn_wrong_ret1 f2;
> > +     func_proto_typedef___fn_wrong_ret2 f3;
> > +     func_proto_typedef___fn_wrong_ret3 f4;
> > +     func_proto_typedef___fn_wrong_arg f5;
> > +     func_proto_typedef___fn_wrong_arg_cnt1 f6;
> > +     func_proto_typedef___fn_wrong_arg_cnt2 f7;
> > +};
> > +
>
> empty line at the end of file?

you cut the line showing which file it is, so I had to guess :) but fixed

>
> > diff --git a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c
> > index aba928fd60d3..145028b52ad8 100644
> > --- a/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c
> > +++ b/tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c
> > @@ -3,6 +3,7 @@
> >
> >   #include <linux/bpf.h>
> >   #include <stdint.h>
> > +#include <stdbool.h>
> >   #include <bpf/bpf_helpers.h>
> >   #include <bpf/bpf_core_read.h>
> >
> > @@ -11,6 +12,7 @@ char _license[] SEC("license") = "GPL";
> >   struct {
> >       char in[256];
> >       char out[256];
> > +     bool skip;
> >       uint64_t my_pid_tgid;
> >   } data = {};
> >
> [...]
> > +
> > +SEC("raw_tracepoint/sys_enter")
> > +int test_core_type_based(void *ctx)
> > +{
> > +#if __has_builtin(__builtin_preserve_type_info)
> > +     struct core_reloc_type_based_output *out = (void *)&data.out;
> > +
> > +     out->struct_exists = bpf_core_type_exists(struct a_struct);
> > +     out->union_exists = bpf_core_type_exists(union a_union);
> > +     out->enum_exists = bpf_core_type_exists(enum an_enum);
> > +     out->typedef_named_struct_exists = bpf_core_type_exists(named_struct_typedef);
> > +     out->typedef_anon_struct_exists = bpf_core_type_exists(anon_struct_typedef);
> > +     out->typedef_struct_ptr_exists = bpf_core_type_exists(struct_ptr_typedef);
> > +     out->typedef_int_exists = bpf_core_type_exists(int_typedef);
> > +     out->typedef_enum_exists = bpf_core_type_exists(enum_typedef);
> > +     out->typedef_void_ptr_exists = bpf_core_type_exists(void_ptr_typedef);
> > +     out->typedef_func_proto_exists = bpf_core_type_exists(func_proto_typedef);
> > +     out->typedef_arr_exists = bpf_core_type_exists(arr_typedef);
> > +
> > +     out->struct_sz = bpf_core_type_size(struct a_struct);
> > +     out->union_sz = bpf_core_type_size(union a_union);
> > +     out->enum_sz = bpf_core_type_size(enum an_enum);
> > +     out->typedef_named_struct_sz = bpf_core_type_size(named_struct_typedef);
> > +     out->typedef_anon_struct_sz = bpf_core_type_size(anon_struct_typedef);
> > +     out->typedef_struct_ptr_sz = bpf_core_type_size(struct_ptr_typedef);
> > +     out->typedef_int_sz = bpf_core_type_size(int_typedef);
> > +     out->typedef_enum_sz = bpf_core_type_size(enum_typedef);
> > +     out->typedef_void_ptr_sz = bpf_core_type_size(void_ptr_typedef);
> > +     out->typedef_func_proto_sz = bpf_core_type_size(func_proto_typedef);
> > +     out->typedef_arr_sz = bpf_core_type_size(arr_typedef);
> > +#else
> > +     data.skip = true;
> > +#endif
> > +     return 0;
> > +}
> > +
>
> empty line at the end of file?

fixed

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ