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  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:   Mon, 28 Sep 2020 21:42:22 -0700
From:   Andrii Nakryiko <>
To:     Alan Maguire <>
Cc:     Alexei Starovoitov <>,
        Daniel Borkmann <>,
        Andrii Nakryiko <>, Yonghong Song <>,
        Rasmus Villemoes <>,, Petr Mladek <>,
        Martin Lau <>, Song Liu <>,
        john fastabend <>,
        KP Singh <>, Shuah Khan <>,
        Andrey Ignatov <>,,
        Quentin Monnet <>,
        Carlos Neira <>,
        Jakub Sitnicki <>,
        Ingo Molnar <>,
        Steven Rostedt <>,
        Arnaldo Carvalho de Melo <>,
        bpf <>, Networking <>,
        open list <>,
        "open list:KERNEL SELFTEST FRAMEWORK" 
Subject: Re: [PATCH v7 bpf-next 8/8] selftests/bpf: add test for
 bpf_seq_printf_btf helper

On Mon, Sep 28, 2020 at 4:36 AM Alan Maguire <> wrote:
> Add a test verifying iterating over tasks and displaying BTF
> representation of task_struct succeeds.
> Suggested-by: Alexei Starovoitov <>
> Signed-off-by: Alan Maguire <>
> ---

Hey Alan,

These selftests rely on having struct btf_ptr and BTF_F_COMPACT (and
other) flags to be present in vmlinux.h. While there is nothing wrong
with that per se, it does break selftests builds on older kernels,
because there struct btf_ptr isn't yet present in kernel:

progs/netif_receive_skb.c:131:21: error: use of undeclared identifier
        TEST_BTF(str, int, BTF_F_NONAME, "0", 0);
progs/netif_receive_skb.c:131:2: error: use of undeclared identifier
'BTF_F_COMPACT'; did you mean 'TT_COMPAT'?
        TEST_BTF(str, int, BTF_F_NONAME, "0", 0);
progs/netif_receive_skb.c:50:28: note: expanded from macro 'TEST_BTF'
                __u64 _hflags = _flags | BTF_F_COMPACT;                 \
note: 'TT_COMPAT' declared here
        TT_COMPAT = 2,
fatal error: too many errors emitted, stopping now [-ferror-limit=]

progs/bpf_iter_task_btf.c:21:24: error: variable has incomplete type
'struct btf_ptr'
        static struct btf_ptr ptr = { };
note: forward declaration of 'struct btf_ptr'
struct btf_ptr;

We actually do build the very latest selftests against old kernels
(4.9 and 5.5 at the moment) as part of libbpf CI, so it would be nice
to fix this problem and keep selftests compilable.

Do you mind following up with a change to define struct btf_ptr and
those BTF_F_xxx flags explicitly for selftests only, similarly to how
we do it for bpf_iter context structs? See progs/bpf_iter.h for
examples. Thanks.

>  tools/testing/selftests/bpf/prog_tests/bpf_iter.c  | 74 ++++++++++++++++++++++
>  .../selftests/bpf/progs/bpf_iter_task_btf.c        | 50 +++++++++++++++
>  2 files changed, 124 insertions(+)
>  create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_task_btf.c


Powered by blists - more mailing lists