BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jianlin Shi" <shijianlin11@foxmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 5/5] selftests/bpf: cover stream capacity and partial read edge cases
Date: Sat, 15 Aug 2026 08:27:00 +0000	[thread overview]
Message-ID: <20260815082700.E74B61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <tencent_E2FD478B453F740591952AA7A502D4FCA609@qq.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The `test_stream_oversize` test fails to verify its stated goal because it uses a completely different BPF program to verify the capacity rollback.
--

--- Patch [5]: [PATCH bpf-next v3 5/5] selftests/bpf: cover stream capacity and partial read edge cases ---
commit 168aa19f7a74d7d1bc5cd6a9913bc5c68df1058d
Author: Jianlin Shi <shijianlin11@foxmail.com>

selftests/bpf: cover stream capacity and partial read edge cases

This commit adds test coverage for stream capacity rollback after oversized
writes and partial reads when buffers straddle unmapped pages.

> diff --git a/tools/testing/selftests/bpf/prog_tests/stream.c b/tools/testing/selftests/bpf/prog_tests/stream.c
> index e4e9374309e26..fefe6431dc7c9 100644
> --- a/tools/testing/selftests/bpf/prog_tests/stream.c
> +++ b/tools/testing/selftests/bpf/prog_tests/stream.c
[ ... ]
> @@ -58,6 +58,76 @@ void test_stream_syscall(void)
>  	stream__destroy(skel);
>  }
>  
> +void test_stream_oversize(void)
> +{
> +	LIBBPF_OPTS(bpf_test_run_opts, opts);
> +	struct stream *skel;
> +	int ret, prog_fd;
> +	char buf[8] = {};
> +
> +	skel = stream__open_and_load();
> +	if (!ASSERT_OK_PTR(skel, "stream__open_and_load"))
> +		return;
> +
> +	prog_fd = bpf_program__fd(skel->progs.stream_oversize);
> +	ret = bpf_prog_test_run_opts(prog_fd, &opts);
> +	ASSERT_OK(ret, "oversize run");
> +	ASSERT_EQ(opts.retval, -E2BIG, "oversize retval");
> +
> +	/* Oversized push must not permanently consume capacity. */
> +	prog_fd = bpf_program__fd(skel->progs.stream_syscall);

[Severity: Medium]
Does this code verify the capacity rollback correctly?

Because BPF streams are maintained on a per-program basis, switching to
the stream_syscall program means it tests a completely different, pristine
stream that was never affected by the oversized push.

Should the test verify a subsequent successful push using the same program
that performed the oversized push?

> +	ret = bpf_prog_test_run_opts(prog_fd, &opts);
> +	ASSERT_OK(ret, "syscall run");
> +	ASSERT_OK(opts.retval, "syscall retval");
> +
> +	ret = bpf_prog_stream_read(prog_fd, BPF_STREAM_STDOUT, buf, sizeof(buf), NULL);
> +	ASSERT_EQ(ret, 3, "bytes after oversize");
> +	ASSERT_OK(memcmp(buf, "foo", 3), "payload after oversize");
> +
> +	stream__destroy(skel);
> +}
[ ... ]
> diff --git a/tools/testing/selftests/bpf/progs/stream.c b/tools/testing/selftests/bpf/progs/stream.c
> index 00a37933e411d..6aa9a67483500 100644
> --- a/tools/testing/selftests/bpf/progs/stream.c
> +++ b/tools/testing/selftests/bpf/progs/stream.c
[ ... ]
> @@ -118,6 +123,13 @@ int stream_syscall(void *ctx)
>  	return 0;
>  }
>  
> +SEC("syscall")
> +__success __retval(-E2BIG)
> +int stream_oversize(void *ctx)
> +{
> +	return bpf_stream_printk(BPF_STDOUT, _BIG_STR);
> +}

[Severity: Medium]
Since this program returns immediately after the oversized push, it leaves
no way to verify the capacity rollback on the same stream from userspace.

Could this program be updated to perform a subsequent successful push to the
same stream, to correctly validate that the capacity was not permanently
consumed?

> +
>  SEC("syscall")
>  __arch_x86_64
>  __arch_arm64

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260815081920.609936-1-shijianlin11@foxmail.com?part=5

  parent reply	other threads:[~2026-08-15  8:27 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20  1:23 [PATCH bpf] bpf: roll back stream capacity when allocation fails Jianlin Shi
2026-07-20  1:35 ` sashiko-bot
2026-07-20  3:40 ` Pu Lehui
2026-07-20  5:13   ` Jianlin Shi
2026-07-20  5:13 ` [PATCH bpf-next v2] " Jianlin Shi
2026-07-20  5:26   ` sashiko-bot
2026-07-27  3:40   ` Jianlin Shi
2026-07-27  3:58   ` Pu Lehui
2026-08-03  2:40   ` Kumar Kartikeya Dwivedi
2026-08-06 15:49     ` Jianlin Shi
2026-08-15  8:19   ` [PATCH bpf-next v3 0/5] bpf: fix stream capacity, read, and oversize handling Jianlin Shi
     [not found]   ` <20260815081920.609936-1-shijianlin11@foxmail.com>
2026-08-15  8:19     ` [PATCH bpf-next v3 1/5] bpf: roll back stream capacity when allocation fails Jianlin Shi
2026-08-15  8:32       ` sashiko-bot
2026-08-15  8:19     ` [PATCH bpf-next v3 2/5] bpf: fix stream capacity leak in staging path Jianlin Shi
2026-08-15  8:32       ` sashiko-bot
2026-08-15  9:02       ` bot+bpf-ci
2026-08-23 14:32         ` Jianlin Shi
2026-08-15  8:19     ` [PATCH bpf-next v3 3/5] bpf: return partial progress from bpf_stream_read on fault Jianlin Shi
2026-08-15  8:19     ` [PATCH bpf-next v3 4/5] bpf: reject oversized bpf_stream_vprintk output with -E2BIG Jianlin Shi
     [not found]     ` <tencent_E2FD478B453F740591952AA7A502D4FCA609@qq.com>
2026-08-15  8:27       ` sashiko-bot [this message]
2026-08-23 14:37         ` [PATCH bpf-next v3 5/5] selftests/bpf: cover stream capacity and partial read edge cases Jianlin Shi
2026-08-23 14:17 ` [PATCH bpf-next v4 0/5] bpf: fix stream capacity, read, and oversize handling Jianlin Shi
2026-08-23 14:17   ` [PATCH bpf-next v4 1/5] bpf: roll back stream capacity when allocation fails Jianlin Shi
2026-08-23 19:20     ` patchwork-bot+netdevbpf
2026-08-23 14:17   ` [PATCH bpf-next v4 2/5] bpf: fix stream capacity leak in staging path Jianlin Shi
2026-08-23 14:17   ` [PATCH bpf-next v4 3/5] bpf: return partial progress from bpf_stream_read on fault Jianlin Shi
2026-08-23 14:29     ` sashiko-bot
2026-08-23 14:17   ` [PATCH bpf-next v4 4/5] bpf: reject oversized bpf_stream_vprintk output with -E2BIG Jianlin Shi
2026-08-23 15:10     ` bot+bpf-ci
2026-08-23 14:17   ` [PATCH bpf-next v4 5/5] selftests/bpf: cover stream capacity and partial read edge cases Jianlin Shi
2026-08-23 14:28     ` sashiko-bot
2026-08-23 15:10     ` bot+bpf-ci
2026-08-23 19:22   ` [PATCH bpf-next v4 0/5] bpf: fix stream capacity, read, and oversize handling Kumar Kartikeya Dwivedi

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=20260815082700.E74B61F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=shijianlin11@foxmail.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