From: David Vernet <void@manifault.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
andrii@kernel.org, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, sdf@google.com, haoluo@google.com,
jolsa@kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, tj@kernel.org
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Add test for resizing data map with struct_ops
Date: Wed, 24 Jul 2024 21:54:59 -0500 [thread overview]
Message-ID: <20240725025459.GA26226@maniforge> (raw)
In-Reply-To: <CAEf4BzY6cc5L7_Yj3XvyCSZGxL=-Vb0g3drFRcsxDd9UB0QC9Q@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2376 bytes --]
On Wed, Jul 24, 2024 at 05:12:00PM -0700, Andrii Nakryiko wrote:
> On Wed, Jul 24, 2024 at 10:15 AM David Vernet <void@manifault.com> wrote:
> >
> > Tests that if you resize a map after opening a skel, that it doesn't
> > cause a UAF which causes a struct_ops map to fail to be able to load.
> >
> > Signed-off-by: David Vernet <void@manifault.com>
> > ---
> > .../bpf/prog_tests/struct_ops_resize.c | 30 +++++++++++++++++++
> > .../selftests/bpf/progs/struct_ops_resize.c | 24 +++++++++++++++
> > 2 files changed, 54 insertions(+)
> > create mode 100644 tools/testing/selftests/bpf/prog_tests/struct_ops_resize.c
> > create mode 100644 tools/testing/selftests/bpf/progs/struct_ops_resize.c
> >
> > diff --git a/tools/testing/selftests/bpf/prog_tests/struct_ops_resize.c b/tools/testing/selftests/bpf/prog_tests/struct_ops_resize.c
> > new file mode 100644
> > index 000000000000..7584f91c2bd1
> > --- /dev/null
> > +++ b/tools/testing/selftests/bpf/prog_tests/struct_ops_resize.c
> > @@ -0,0 +1,30 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +
> > +#include <test_progs.h>
> > +#include "struct_ops_resize.skel.h"
> > +
> > +static void resize_datasec(void)
> > +{
> > + struct struct_ops_resize *skel;
> > + int err;
> > +
> > + skel = struct_ops_resize__open();
> > + if (!ASSERT_OK_PTR(skel, "struct_ops_resize__open"))
> > + return;
> > +
> > + err = bpf_map__set_value_size(skel->maps.data_resizable, 1 << 15);
> > + if (!ASSERT_OK(err, "bpf_map__set_value_size"))
> > + goto cleanup;
> > +
> > + err = struct_ops_resize__load(skel);
> > + ASSERT_OK(err, "struct_ops_resize__load");
> > +
> > +cleanup:
> > + struct_ops_resize__destroy(skel);
> > +}
> > +
> > +void test_struct_ops_resize(void)
> > +{
> > + if (test__start_subtest("resize_datasec"))
> > + resize_datasec();
>
> It seems a bit unnecessary to add an entire new test with a subtest
> just for this. Would you mind adding this testing logic into the
> already existing prog_tests/global_map_resize.c set of cases?
Sure thing, I'll send a subsequent patch that adds the testcase to
prog_tests/global_map_resize.c.
> I've applied patch #1, as it's obviously correct, so I didn't want to
> delay the fix. Thanks!
Thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2024-07-25 2:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 17:14 [PATCH bpf-next 1/2] libbpf: Don't take direct pointers into BTF data from st_ops David Vernet
2024-07-24 17:14 ` [PATCH bpf-next 2/2] selftests/bpf: Add test for resizing data map with struct_ops David Vernet
2024-07-25 0:12 ` Andrii Nakryiko
2024-07-25 2:54 ` David Vernet [this message]
2024-07-25 0:20 ` [PATCH bpf-next 1/2] libbpf: Don't take direct pointers into BTF data from st_ops patchwork-bot+netdevbpf
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=20240725025459.GA26226@maniforge \
--to=void@manifault.com \
--cc=andrii.nakryiko@gmail.com \
--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=kernel-team@meta.com \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=tj@kernel.org \
--cc=yonghong.song@linux.dev \
/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