mbox series

[bpf-next,v1,0/2] Ensure type tags are always ordered first in BTF

Message ID 20220406004121.282699-1-memxor@gmail.com (mailing list archive)
Headers show
Series Ensure type tags are always ordered first in BTF | expand

Message

Kumar Kartikeya Dwivedi April 6, 2022, 12:41 a.m. UTC
When iterating over modifiers, ensure that type tags can only occur at head of
the chain, and don't occur later, such that checking for them once in the start
tells us there are no more type tags in later modifiers. Clang already ensures
to emit such BTF, but user can craft their own BTF which violates such
assumptions if relied upon in the kernel.

Kumar Kartikeya Dwivedi (2):
  bpf: Ensure type tags precede modifiers in BTF
  selftests/bpf: Add tests for type tag order validation

 kernel/bpf/btf.c                             | 51 +++++++++++++
 tools/testing/selftests/bpf/prog_tests/btf.c | 77 ++++++++++++++++++++
 2 files changed, 128 insertions(+)

Comments

Andrii Nakryiko April 13, 2022, 3:23 a.m. UTC | #1
On Tue, Apr 5, 2022 at 5:41 PM Kumar Kartikeya Dwivedi <memxor@gmail.com> wrote:
>
> When iterating over modifiers, ensure that type tags can only occur at head of
> the chain, and don't occur later, such that checking for them once in the start
> tells us there are no more type tags in later modifiers. Clang already ensures
> to emit such BTF, but user can craft their own BTF which violates such
> assumptions if relied upon in the kernel.
>
> Kumar Kartikeya Dwivedi (2):
>   bpf: Ensure type tags precede modifiers in BTF
>   selftests/bpf: Add tests for type tag order validation
>
>  kernel/bpf/btf.c                             | 51 +++++++++++++
>  tools/testing/selftests/bpf/prog_tests/btf.c | 77 ++++++++++++++++++++
>  2 files changed, 128 insertions(+)
>
> --
> 2.35.1
>

Yonghong, can you please take a look?