bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
       [not found] <20230320005258.1428043-1-sashal@kernel.org>
@ 2023-03-20  0:52 ` Sasha Levin
  2023-03-20 15:31   ` Lorenz Bauer
  0 siblings, 1 reply; 11+ messages in thread
From: Sasha Levin @ 2023-03-20  0:52 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Lorenz Bauer, Lorenz Bauer, Martin KaFai Lau, Sasha Levin, ast,
	daniel, andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor,
	bpf, linux-kselftest

From: Lorenz Bauer <lorenz.bauer@isovalent.com>

[ Upstream commit dfdd608c3b365f0fd49d7e13911ebcde06b9865b ]

Add a regression test that ensures that a VAR pointing at a
modifier which follows a PTR (or STRUCT or ARRAY) is resolved
correctly by the datasec validator.

Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Link: https://lore.kernel.org/r/20230306112138.155352-3-lmb@isovalent.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/testing/selftests/bpf/prog_tests/btf.c | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/btf.c b/tools/testing/selftests/bpf/prog_tests/btf.c
index de1b5b9eb93a8..d8d1292e73b53 100644
--- a/tools/testing/selftests/bpf/prog_tests/btf.c
+++ b/tools/testing/selftests/bpf/prog_tests/btf.c
@@ -879,6 +879,34 @@ static struct btf_raw_test raw_tests[] = {
 	.btf_load_err = true,
 	.err_str = "Invalid elem",
 },
+{
+	.descr = "var after datasec, ptr followed by modifier",
+	.raw_types = {
+		/* .bss section */				/* [1] */
+		BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2),
+			sizeof(void*)+4),
+		BTF_VAR_SECINFO_ENC(4, 0, sizeof(void*)),
+		BTF_VAR_SECINFO_ENC(6, sizeof(void*), 4),
+		/* int */					/* [2] */
+		BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4),
+		/* int* */					/* [3] */
+		BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 2),
+		BTF_VAR_ENC(NAME_TBD, 3, 0),			/* [4] */
+		/* const int */					/* [5] */
+		BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 2),
+		BTF_VAR_ENC(NAME_TBD, 5, 0),			/* [6] */
+		BTF_END_RAW,
+	},
+	.str_sec = "\0a\0b\0c\0",
+	.str_sec_size = sizeof("\0a\0b\0c\0"),
+	.map_type = BPF_MAP_TYPE_ARRAY,
+	.map_name = ".bss",
+	.key_size = sizeof(int),
+	.value_size = sizeof(void*)+4,
+	.key_type_id = 0,
+	.value_type_id = 1,
+	.max_entries = 1,
+},
 /* Test member exceeds the size of struct.
  *
  * struct A {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-03-20  0:52 ` [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer Sasha Levin
@ 2023-03-20 15:31   ` Lorenz Bauer
  2023-03-20 15:48     ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Lorenz Bauer @ 2023-03-20 15:31 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, Martin KaFai Lau, ast, daniel, andrii,
	shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Mon, Mar 20, 2023 at 12:53 AM Sasha Levin <sashal@kernel.org> wrote:
>
> From: Lorenz Bauer <lorenz.bauer@isovalent.com>
>
> [ Upstream commit dfdd608c3b365f0fd49d7e13911ebcde06b9865b ]
>
> Add a regression test that ensures that a VAR pointing at a
> modifier which follows a PTR (or STRUCT or ARRAY) is resolved
> correctly by the datasec validator.
>
> Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
> Link: https://lore.kernel.org/r/20230306112138.155352-3-lmb@isovalent.com
> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
> Signed-off-by: Sasha Levin <sashal@kernel.org>

Hi Sasha,

Can you explain why this patch was selected? I'd prefer to not
backport the test, since it frequently leads to breakage when trying
to build selftests/bpf on stable kernels.

Thanks
Lorenz

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-03-20 15:31   ` Lorenz Bauer
@ 2023-03-20 15:48     ` Greg KH
  2023-03-28 10:18       ` Lorenz Bauer
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2023-03-20 15:48 UTC (permalink / raw)
  To: Lorenz Bauer
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Mon, Mar 20, 2023 at 03:31:42PM +0000, Lorenz Bauer wrote:
> On Mon, Mar 20, 2023 at 12:53 AM Sasha Levin <sashal@kernel.org> wrote:
> >
> > From: Lorenz Bauer <lorenz.bauer@isovalent.com>
> >
> > [ Upstream commit dfdd608c3b365f0fd49d7e13911ebcde06b9865b ]
> >
> > Add a regression test that ensures that a VAR pointing at a
> > modifier which follows a PTR (or STRUCT or ARRAY) is resolved
> > correctly by the datasec validator.
> >
> > Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
> > Link: https://lore.kernel.org/r/20230306112138.155352-3-lmb@isovalent.com
> > Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
> > Signed-off-by: Sasha Levin <sashal@kernel.org>
> 
> Hi Sasha,
> 
> Can you explain why this patch was selected? I'd prefer to not
> backport the test, since it frequently leads to breakage when trying
> to build selftests/bpf on stable kernels.

Why would it break?  Is that because the test is buggy, or the kernel is
buggy?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-03-20 15:48     ` Greg KH
@ 2023-03-28 10:18       ` Lorenz Bauer
  2023-04-11 15:08         ` Lorenz Bauer
  0 siblings, 1 reply; 11+ messages in thread
From: Lorenz Bauer @ 2023-03-28 10:18 UTC (permalink / raw)
  To: Greg KH
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Mon, Mar 20, 2023 at 3:48 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> Why would it break?  Is that because the test is buggy, or the kernel is
> buggy?

This test will be fine, but there have been several times when
selftests/bpf for stable kernel releases didn't actually compile due
to backported tests. This is because macros we're redefined, etc.
Unless those also get picked (seems like a sisyphean task) we'll keep
seeing broken selftests/bpf on stable.

Best
Lorenz

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-03-28 10:18       ` Lorenz Bauer
@ 2023-04-11 15:08         ` Lorenz Bauer
  2023-04-11 15:14           ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Lorenz Bauer @ 2023-04-11 15:08 UTC (permalink / raw)
  To: Greg KH
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Tue, Mar 28, 2023 at 11:18 AM Lorenz Bauer <lmb@isovalent.com> wrote:
>
> On Mon, Mar 20, 2023 at 3:48 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > Why would it break?  Is that because the test is buggy, or the kernel is
> > buggy?
>
> This test will be fine, but there have been several times when
> selftests/bpf for stable kernel releases didn't actually compile due
> to backported tests. This is because macros we're redefined, etc.
> Unless those also get picked (seems like a sisyphean task) we'll keep
> seeing broken selftests/bpf on stable.

Hi Greg, Sasha,

Following up on this since it seems to have fallen through the cracks.

Lorenz

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-04-11 15:08         ` Lorenz Bauer
@ 2023-04-11 15:14           ` Greg KH
  2023-05-24 11:03             ` Lorenz Bauer
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2023-04-11 15:14 UTC (permalink / raw)
  To: Lorenz Bauer
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Tue, Apr 11, 2023 at 04:08:32PM +0100, Lorenz Bauer wrote:
> On Tue, Mar 28, 2023 at 11:18 AM Lorenz Bauer <lmb@isovalent.com> wrote:
> >
> > On Mon, Mar 20, 2023 at 3:48 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > Why would it break?  Is that because the test is buggy, or the kernel is
> > > buggy?
> >
> > This test will be fine, but there have been several times when
> > selftests/bpf for stable kernel releases didn't actually compile due
> > to backported tests. This is because macros we're redefined, etc.
> > Unless those also get picked (seems like a sisyphean task) we'll keep
> > seeing broken selftests/bpf on stable.
> 
> Hi Greg, Sasha,
> 
> Following up on this since it seems to have fallen through the cracks.

I didn't see anything to do here.

And selftests should NOT be broken on stable releases, if so, something
is wrong as no other subsystem has that happen.

confused,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-04-11 15:14           ` Greg KH
@ 2023-05-24 11:03             ` Lorenz Bauer
  2023-05-24 16:03               ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Lorenz Bauer @ 2023-05-24 11:03 UTC (permalink / raw)
  To: Greg KH
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Tue, Apr 11, 2023 at 4:14 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> I didn't see anything to do here.
>
> And selftests should NOT be broken on stable releases, if so, something
> is wrong as no other subsystem has that happen.

Sorry for the long delay in replying, I update the kernels we use for
CI only infrequently. Here is an example of the build failure I'm
seeing, from kernel.org 5.10 LTS:

In file included from
/work/build/5.10.180/tools/testing/selftests/bpf/verifier/tests.h:59,
                 from test_verifier.c:355:
/work/build/5.10.180/tools/testing/selftests/bpf/verifier/ref_tracking.c:935:3:
error: 'struct bpf_test' has no member named 'fixup_map_ringbuf'; did
you mean 'fixup_map_in_map'?
  935 |  .fixup_map_ringbuf = { 11 },
      |   ^~~~~~~~~~~~~~~~~
      |   fixup_map_in_map

This is just doing make -C tools/testing/selftests/bpf after compiling a kernel.

Best
Lorenz

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-05-24 11:03             ` Lorenz Bauer
@ 2023-05-24 16:03               ` Greg KH
  2023-05-24 17:04                 ` Lorenz Bauer
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2023-05-24 16:03 UTC (permalink / raw)
  To: Lorenz Bauer
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Wed, May 24, 2023 at 12:03:43PM +0100, Lorenz Bauer wrote:
> On Tue, Apr 11, 2023 at 4:14 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > I didn't see anything to do here.
> >
> > And selftests should NOT be broken on stable releases, if so, something
> > is wrong as no other subsystem has that happen.
> 
> Sorry for the long delay in replying, I update the kernels we use for
> CI only infrequently. Here is an example of the build failure I'm
> seeing, from kernel.org 5.10 LTS:
> 
> In file included from
> /work/build/5.10.180/tools/testing/selftests/bpf/verifier/tests.h:59,
>                  from test_verifier.c:355:
> /work/build/5.10.180/tools/testing/selftests/bpf/verifier/ref_tracking.c:935:3:
> error: 'struct bpf_test' has no member named 'fixup_map_ringbuf'; did
> you mean 'fixup_map_in_map'?
>   935 |  .fixup_map_ringbuf = { 11 },
>       |   ^~~~~~~~~~~~~~~~~
>       |   fixup_map_in_map
> 
> This is just doing make -C tools/testing/selftests/bpf after compiling a kernel.

Great, any specific commits that fix this issue would be appreciated to
be pointed at so we can apply them.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-05-24 16:03               ` Greg KH
@ 2023-05-24 17:04                 ` Lorenz Bauer
  2023-05-26 16:43                   ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Lorenz Bauer @ 2023-05-24 17:04 UTC (permalink / raw)
  To: Greg KH
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Wed, May 24, 2023 at 5:04 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> Great, any specific commits that fix this issue would be appreciated to
> be pointed at so we can apply them.

The problem was introduced by commit f4b8c0710ab6 ("selftests/bpf: Add
verifier test for release_reference()") in your tree. Seems like
fixup_map_ringbuf was introduced in upstream commit 4237e9f4a962
("selftests/bpf: Add verifier test for PTR_TO_MEM spill") but that
wasn't backported.

To restate my original question: how can we avoid breaking BPF
selftests? From personal experience this happens somewhat regularly.

Best
Lorenz

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-05-24 17:04                 ` Lorenz Bauer
@ 2023-05-26 16:43                   ` Greg KH
  2023-05-30 11:24                     ` Lorenz Bauer
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2023-05-26 16:43 UTC (permalink / raw)
  To: Lorenz Bauer
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Wed, May 24, 2023 at 06:04:43PM +0100, Lorenz Bauer wrote:
> On Wed, May 24, 2023 at 5:04 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > Great, any specific commits that fix this issue would be appreciated to
> > be pointed at so we can apply them.
> 
> The problem was introduced by commit f4b8c0710ab6 ("selftests/bpf: Add
> verifier test for release_reference()") in your tree. Seems like
> fixup_map_ringbuf was introduced in upstream commit 4237e9f4a962
> ("selftests/bpf: Add verifier test for PTR_TO_MEM spill") but that
> wasn't backported.

So what tree(s) does this need to be backported to?  I'm confused, this
is a 6.2 email thread which is long end-of-life.

> To restate my original question: how can we avoid breaking BPF
> selftests? From personal experience this happens somewhat regularly.

It can be avoided by people testing and letting me know when things
break :)

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer
  2023-05-26 16:43                   ` Greg KH
@ 2023-05-30 11:24                     ` Lorenz Bauer
  0 siblings, 0 replies; 11+ messages in thread
From: Lorenz Bauer @ 2023-05-30 11:24 UTC (permalink / raw)
  To: Greg KH
  Cc: Sasha Levin, linux-kernel, stable, Martin KaFai Lau, ast, daniel,
	andrii, shuah, yhs, eddyz87, sdf, error27, iii, memxor, bpf,
	linux-kselftest

On Fri, May 26, 2023 at 6:43 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> So what tree(s) does this need to be backported to?  I'm confused, this
> is a 6.2 email thread which is long end-of-life.

That would be 5.10 from what I can tell. Other LTS kernels have
working tools/testing/selftests/bpf.

I replied here because you asked for examples :)

> It can be avoided by people testing and letting me know when things
> break :)

Fair enough. Earlier you said:

> And selftests should NOT be broken on stable releases, if so, something
> is wrong as no other subsystem has that happen.

Why is bpf special in this regard then?

Best
Lorenz

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-05-30 11:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20230320005258.1428043-1-sashal@kernel.org>
2023-03-20  0:52 ` [PATCH AUTOSEL 6.2 08/30] selftests/bpf: check that modifier resolves after pointer Sasha Levin
2023-03-20 15:31   ` Lorenz Bauer
2023-03-20 15:48     ` Greg KH
2023-03-28 10:18       ` Lorenz Bauer
2023-04-11 15:08         ` Lorenz Bauer
2023-04-11 15:14           ` Greg KH
2023-05-24 11:03             ` Lorenz Bauer
2023-05-24 16:03               ` Greg KH
2023-05-24 17:04                 ` Lorenz Bauer
2023-05-26 16:43                   ` Greg KH
2023-05-30 11:24                     ` Lorenz Bauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).