]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - kernel/bpf/bpf_iter.c
bpf: Implement bpf_seq_read() for bpf iterator
authorYonghong Song <yhs@fb.com>
Sat, 9 May 2020 17:59:04 +0000 (10:59 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 10 May 2020 00:05:26 +0000 (17:05 -0700)
commitfd4f12bc38c3ad9107169e7c9e6e7f81d93dda97
treeb56407cffddf4ca487a888d9f2cb75b45e53a9e8
parent2057c92bc927f09b22f5609425eb37d7e782f484
bpf: Implement bpf_seq_read() for bpf iterator

bpf iterator uses seq_file to provide a lossless
way to transfer data to user space. But we want to call
bpf program after all objects have been traversed, and
bpf program may write additional data to the
seq_file buffer. The current seq_read() does not work
for this use case.

Besides allowing stop() function to write to the buffer,
the bpf_seq_read() also fixed the buffer size to one page.
If any single call of show() or stop() will emit data
more than one page to cause overflow, -E2BIG error code
will be returned to user space.

Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200509175904.2475468-1-yhs@fb.com
kernel/bpf/bpf_iter.c