From: Yonghong Song <yonghong.song@linux.dev>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>
Subject: [PATCH bpf-next 0/3] bpf: Allow 'may_goto 0' instruction
Date: Wed, 15 Jan 2025 21:51:23 -0800 [thread overview]
Message-ID: <20250116055123.603790-1-yonghong.song@linux.dev> (raw)
Emil Tsalapatis from Meta reported such a case where 'may_goto 0' insn is
generated by clang-19 compiler and this caused verification failure
since 'may_goto 0' is rejected by verifier.
In fact, 'may_goto 0' insn is actually a no-op and it won't hurt
verification. The only side effect is that the verifier will convert
the insn to a sequence of codes like
/* r10 - 8 stores the implicit loop count */
r11 = *(u64 *)(r10 -8)
if r11 == 0x0 goto pc+2
r11 -= 1
*(u64 *)(r10 -8) = r11
With this patch set 'may_goto 0' insns are allowed in verification which
also removes those insns.
Yonghong Song (3):
bpf: Allow 'may_goto 0' instruction
bpf: Remove 'may_goto 0' instruction
selftests/bpf: Add some tests related to 'may_goto 0' insns
kernel/bpf/verifier.c | 41 +++++++-
.../selftests/bpf/prog_tests/verifier.c | 4 +
.../selftests/bpf/progs/verifier_may_goto_1.c | 97 +++++++++++++++++++
.../selftests/bpf/progs/verifier_may_goto_2.c | 28 ++++++
4 files changed, 167 insertions(+), 3 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/verifier_may_goto_1.c
create mode 100644 tools/testing/selftests/bpf/progs/verifier_may_goto_2.c
--
2.43.5
next reply other threads:[~2025-01-16 5:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 5:51 Yonghong Song [this message]
2025-01-16 5:51 ` [PATCH bpf-next 1/3] bpf: Allow 'may_goto 0' instruction Yonghong Song
2025-01-16 19:23 ` Eduard Zingerman
2025-01-16 5:51 ` [PATCH bpf-next 2/3] bpf: Remove " Yonghong Song
2025-01-16 19:42 ` Eduard Zingerman
2025-01-17 1:45 ` Alexei Starovoitov
2025-01-17 3:43 ` Yonghong Song
2025-01-16 5:51 ` [PATCH bpf-next 3/3] selftests/bpf: Add some tests related to 'may_goto 0' insns Yonghong Song
2025-01-16 19:49 ` Eduard Zingerman
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=20250116055123.603790-1-yonghong.song@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
/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