From: Martin KaFai Lau <martin.lau@linux.dev>
To: Lorenz Bauer <lmb@isovalent.com>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>, Song Liu <song@kernel.org>,
Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>
Subject: Re: [PATCH bpf-next] bpf: btf: restore resolve_mode when popping the resolve stack
Date: Wed, 17 May 2023 18:42:06 -0700 [thread overview]
Message-ID: <a453c3d4-5615-f445-17a8-92a1dc4282e6@linux.dev> (raw)
In-Reply-To: <CAN+4W8hixyHYOwYRh-3WedS-a0KTQk8VQ4JxqM8y-DQY-yjsNA@mail.gmail.com>
On 5/17/23 2:01 AM, Lorenz Bauer wrote:
> On Wed, May 17, 2023 at 7:26 AM Martin KaFai Lau <martin.lau@linux.dev> wrote:
>>
>> On 5/15/23 5:15 AM, Lorenz Bauer wrote:
>>> In commit 9b459804ff99 ("btf: fix resolving BTF_KIND_VAR after ARRAY, STRUCT, UNION, PTR")
>>> I fixed a bug that occurred during resolving of a DATASEC by strategically resetting
>>> resolve_mode. This fixes the immediate bug but leaves us open to future bugs where
>>> nested types have to be resolved.
>>
>> hmm... future bugs like when adding new BTF_KIND in the future?
>
> It could just be refactoring of the codebase? What is the downside of
> restoring the mode when popping the item? It also makes push and pop
> symmetrical.
I can see your point to refactor it to make it work for all different BTF_KIND.
Other than BTF_KIND_DATASEC, env->resolve_mode stays the same for all other
kinds once it is decided. It is why resolve_mode is in the "env" instead of "v".
My concern is this will hide some bugs (existing or future) that accidentally
changed the resolve_mode in the middle. If there is another legit case that
could be found other than BTF_KIND_DATASEC, that will be a better time to do
this refactoring with a proper test case considering most bpf progs need btf to
load nowadays and probably need to veristat test also. If it came to that, might
as well consider moving resolve_mode from "env" to "v".
btf_datasec_resolve() is acting as a very top level resolver like btf_resolve(),
so it reset env->resolve_mode before resolving its var member like how
btf_resolve() does. imo, together with env->resolve_mode stays the same for
others, it is more straight forward to reason. I understand that it is personal
preference and could argue either way.
next prev parent reply other threads:[~2023-05-18 1:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-15 12:15 Lorenz Bauer
2023-05-15 19:26 ` Daniel Borkmann
2023-05-16 10:32 ` Lorenz Bauer
2023-05-17 6:26 ` Martin KaFai Lau
2023-05-17 9:01 ` Lorenz Bauer
2023-05-18 1:42 ` Martin KaFai Lau [this message]
2023-05-18 8:42 ` Lorenz Bauer
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=a453c3d4-5615-f445-17a8-92a1dc4282e6@linux.dev \
--to=martin.lau@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lmb@isovalent.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--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
all inboxes | Powered by JetHome®