Skip to content

Conversation

@kernel-patches-daemon-bpf
Copy link

Pull request for series with
subject: bpf: Fix truncated dmabuf iterator reads
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 30f0920
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 30f0920
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 8f7aa3d
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 835a507
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 861111b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279
version: 1

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 861111b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279
version: 1

tweej added 2 commits December 4, 2025 15:53
If there is a large number (hundreds) of dmabufs allocated, the text
output generated from dmabuf_iter_seq_show can exceed common user buffer
sizes (e.g. PAGE_SIZE) necessitating multiple start/stop cycles to
iterate through all dmabufs. However the dmabuf iterator currently
returns NULL in dmabuf_iter_seq_start for all non-zero pos values, which
results in the truncation of the output before all dmabufs are handled.

After dma_buf_iter_begin / dma_buf_iter_next, the refcount of the buffer
is elevated so that the BPF iterator program can run without holding any
locks. When a stop occurs, instead of immediately dropping the reference
on the buffer, stash a pointer to the buffer in seq->priv until
either start is called or the iterator is released. This also enables
the resumption of iteration without first walking through the list of
dmabufs based on the pos value.

Fixes: 76ea955 ("bpf: Add dmabuf iterator")
Signed-off-by: T.J. Mercier <[email protected]>
If many dmabufs are present, reads of the dmabuf iterator can be
truncated at PAGE_SIZE or user buffer size boundaries before the fix in
"selftests/bpf: Add test for open coded dmabuf_iter". Add a test to
confirm truncation does not occur.

Signed-off-by: T.J. Mercier <[email protected]>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 861111b
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=1030279
version: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants