Skip to content

Commit 05ea1b6

Browse files
kkdwvdborkmann
authored andcommitted
selftests/bpf: Cover oversized stream read buffers
Exercise BPF_PROG_STREAM_READ_BY_FD with a UINT_MAX buffer length and require EINVAL. Continue with the existing two-part read of the queued payload to verify that rejecting the oversized request does not consume or otherwise disturb stream data. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20260823193202.2389715-3-memxor@gmail.com
1 parent ea0b60f commit 05ea1b6

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • tools/testing/selftests/bpf/prog_tests

tools/testing/selftests/bpf/prog_tests/stream.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ void test_stream_syscall(void)
4646
ret = -errno;
4747
ASSERT_EQ(ret, -EFAULT, "bad stream buf");
4848

49+
ASSERT_LT(bpf_prog_stream_read(prog_fd, BPF_STREAM_STDOUT, buf, UINT_MAX, NULL), 0, "error");
50+
ret = -errno;
51+
ASSERT_EQ(ret, -EINVAL, "large stream buf");
52+
4953
ret = bpf_prog_stream_read(prog_fd, BPF_STREAM_STDOUT, buf, 2, NULL);
5054
ASSERT_EQ(ret, 2, "bytes");
5155
ret = bpf_prog_stream_read(prog_fd, BPF_STREAM_STDOUT, buf, 2, NULL);

0 commit comments

Comments
 (0)