[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240725025459.GA26226@maniforge>
Date: Wed, 24 Jul 2024 21:54:59 -0500
From: David Vernet <void@...ifault.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: bpf@...r.kernel.org, ast@...nel.org, daniel@...earbox.net,
andrii@...nel.org, martin.lau@...ux.dev, song@...nel.org,
yonghong.song@...ux.dev, john.fastabend@...il.com,
kpsingh@...nel.org, sdf@...gle.com, haoluo@...gle.com,
jolsa@...nel.org, linux-kernel@...r.kernel.org,
kernel-team@...a.com, tj@...nel.org
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: Add test for resizing data
map with struct_ops
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@...ifault.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@...ifault.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!
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists