bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <kafai@fb.com>
To: Yoshiki Komachi <komachi.yoshiki@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	Andrii Nakryiko <andriin@fb.com>, <netdev@vger.kernel.org>,
	<bpf@vger.kernel.org>
Subject: Re: [PATCH v2 bpf 0/2] Fix BTF verification of enum members with a selftest
Date: Tue, 10 Mar 2020 09:46:27 -0700	[thread overview]
Message-ID: <20200310164627.zb3pponhlsweqk45@kafai-mbp> (raw)
In-Reply-To: <1583825550-18606-1-git-send-email-komachi.yoshiki@gmail.com>

On Tue, Mar 10, 2020 at 04:32:28PM +0900, Yoshiki Komachi wrote:
> btf_enum_check_member() checked if the size of "enum" as a struct
> member exceeded struct_size or not. Then, the function compared it
> with the size of "int". Although the size of "enum" is 4-byte by
> default (i.e., equivalent to "int"), the packing feature enables
> us to reduce it, as illustrated by the following example:
> 
> struct A {
>         char m;
>         enum { E0, E1 } __attribute__((packed)) n;
> };
> 
> With such a setup above, the bpf loader gave an error attempting
> to load it:
> 
> ------------------------------------------------------------------
> ...
> 
> [3] ENUM (anon) size=1 vlen=2
>         E0 val=0
>         E1 val=1
> [4] STRUCT A size=2 vlen=2
>         m type_id=2 bits_offset=0
>         n type_id=3 bits_offset=8
> 
> [4] STRUCT A size=2 vlen=2
>         n type_id=3 bits_offset=8 Member exceeds struct_size
> 
> libbpf: Error loading .BTF into kernel: -22.
> 
> ------------------------------------------------------------------
> 
> The related issue was previously fixed by the commit 9eea98497951 ("bpf:
> fix BTF verification of enums"). On the other hand, this series fixes
> this issue as well, and adds a selftest program for it.
> 
> Changes in v2:
> - change an example in commit message based on Andrii's review
> - add a selftest program for packed "enum" type members in struct/union
Acked-by: Martin KaFai Lau <kafai@fb.com>

  parent reply	other threads:[~2020-03-10 16:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  7:32 [PATCH v2 bpf 0/2] Fix BTF verification of enum members with a selftest Yoshiki Komachi
2020-03-10  7:32 ` [PATCH bpf 1/2] bpf/btf: Fix BTF verification of enum members in struct/union Yoshiki Komachi
2020-03-10  7:32 ` [PATCH bpf 2/2] selftests/bpf: Add test for the packed enum member " Yoshiki Komachi
2020-03-10 15:39 ` [PATCH v2 bpf 0/2] Fix BTF verification of enum members with a selftest Andrii Nakryiko
2020-03-10 16:46 ` Martin KaFai Lau [this message]
2020-03-10 17:26   ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200310164627.zb3pponhlsweqk45@kafai-mbp \
    --to=kafai@fb.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=komachi.yoshiki@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).