From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, kernel-team@fb.com, yhs@fb.com,
memxor@gmail.com, ecree.xilinx@gmail.com
Subject: Re: [PATCH bpf-next 0/7] stricter register ID checking in regsafe()
Date: Wed, 14 Dec 2022 18:28:09 +0200 [thread overview]
Message-ID: <c5f8a5d0b87a48715aa66a3e27f4f17b8544f87a.camel@gmail.com> (raw)
In-Reply-To: <CAEf4BzbUxdxJMZ2Ln+7jD8+kq0hiea-XJU4VY5W06dJ_KWJC3Q@mail.gmail.com>
On Tue, 2022-12-13 at 16:34 -0800, Andrii Nakryiko wrote:
> On Fri, Dec 9, 2022 at 5:58 AM Eduard Zingerman <eddyz87@gmail.com> wrote:
> >
> > This patch-set consists of a series of bug fixes for register ID
> > tracking in verifier.c:states_equal()/regsafe() functions:
> > - for registers of type PTR_TO_MAP_{KEY,VALUE}, PTR_TO_PACKET[_META]
> > the regsafe() should call check_ids() even if registers are
> > byte-to-byte equal;
> > - states_equal() must maintain idmap that covers all function frames
> > in the state because functions like mark_ptr_or_null_regs() operate
> > on all registers in the state;
> > - regsafe() must compare spin lock ids for PTR_TO_MAP_VALUE registers.
> >
> > The last point covers issue reported by Kumar Kartikeya Dwivedi in [1],
> > I borrowed the test commit from there.
> > Note, that there is also an issue with register id tracking for
> > scalars described here [2], it would be addressed separately.
> >
>
> Awesome set of patches, thanks for working on this! I left a few
> comments and suggestions, please take a look, and if they do make
> sense, consider sending follow up patches.
>
> Let's really try to use asm() next time for selftests, though.
>
> It would be awesome to somehow automatically move test_verifier's
> tests to this test_progs-based embedded assembly way, but that
> probably takes some Python hackery (awesome project for some curious
> soul, for sure).
>
> Anyways, back to the point I wanted to make. Given you've clearly
> thought about all the ID checks a lot, consider checking refsafe()
> (not regsafe()!) as well. I think we should do check_ids() there as
> well. And you did all the preliminary work with making idmap
> persistent across all frames. Just something to improve (and looks
> straightforward, unlike many other things you've dealt with recently
> ;).
Makes sense, I'll work on it.
>
> Anyways, great work, thanks!
Thank you.
>
> > [1] https://lore.kernel.org/bpf/20221111202719.982118-1-memxor@gmail.com/
> > [2] https://lore.kernel.org/bpf/20221128163442.280187-2-eddyz87@gmail.com/
> >
> > Eduard Zingerman (6):
> > bpf: regsafe() must not skip check_ids()
> > selftests/bpf: test cases for regsafe() bug skipping check_id()
> > bpf: states_equal() must build idmap for all function frames
> > selftests/bpf: verify states_equal() maintains idmap across all frames
> > bpf: use check_ids() for active_lock comparison
> > selftests/bpf: test case for relaxed prunning of active_lock.id
> >
> > Kumar Kartikeya Dwivedi (1):
> > selftests/bpf: Add pruning test case for bpf_spin_lock
> >
> > include/linux/bpf_verifier.h | 4 +-
> > kernel/bpf/verifier.c | 48 ++++----
> > tools/testing/selftests/bpf/verifier/calls.c | 82 +++++++++++++
> > .../bpf/verifier/direct_packet_access.c | 54 +++++++++
> > .../selftests/bpf/verifier/spin_lock.c | 114 ++++++++++++++++++
> > .../selftests/bpf/verifier/value_or_null.c | 49 ++++++++
> > 6 files changed, 324 insertions(+), 27 deletions(-)
> >
> > --
> > 2.34.1
> >
prev parent reply other threads:[~2022-12-14 16:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 13:57 [PATCH bpf-next 0/7] stricter register ID checking in regsafe() Eduard Zingerman
2022-12-09 13:57 ` [PATCH bpf-next 1/7] bpf: regsafe() must not skip check_ids() Eduard Zingerman
2022-12-14 0:35 ` Andrii Nakryiko
2022-12-14 13:25 ` Eduard Zingerman
2022-12-14 19:37 ` Andrii Nakryiko
2022-12-09 13:57 ` [PATCH bpf-next 2/7] selftests/bpf: test cases for regsafe() bug skipping check_id() Eduard Zingerman
2022-12-09 13:57 ` [PATCH bpf-next 3/7] bpf: states_equal() must build idmap for all function frames Eduard Zingerman
2022-12-14 0:35 ` Andrii Nakryiko
2022-12-14 15:33 ` Eduard Zingerman
2022-12-14 17:24 ` Andrii Nakryiko
2022-12-09 13:57 ` [PATCH bpf-next 4/7] selftests/bpf: verify states_equal() maintains idmap across all frames Eduard Zingerman
2022-12-14 0:35 ` Andrii Nakryiko
2022-12-14 16:38 ` Eduard Zingerman
2022-12-14 17:10 ` Andrii Nakryiko
2022-12-09 13:57 ` [PATCH bpf-next 5/7] bpf: use check_ids() for active_lock comparison Eduard Zingerman
2022-12-09 13:57 ` [PATCH bpf-next 6/7] selftests/bpf: Add pruning test case for bpf_spin_lock Eduard Zingerman
2022-12-10 21:45 ` Alexei Starovoitov
2022-12-09 13:57 ` [PATCH bpf-next 7/7] selftests/bpf: test case for relaxed prunning of active_lock.id Eduard Zingerman
2022-12-10 21:50 ` [PATCH bpf-next 0/7] stricter register ID checking in regsafe() patchwork-bot+netdevbpf
2022-12-14 0:34 ` Andrii Nakryiko
2022-12-14 16:28 ` Eduard Zingerman [this message]
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=c5f8a5d0b87a48715aa66a3e27f4f17b8544f87a.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii.nakryiko@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=ecree.xilinx@gmail.com \
--cc=kernel-team@fb.com \
--cc=memxor@gmail.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