Skip to content

sockmap: Fix reading with splice(2) #9280

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: bpf-next_base
Choose a base branch
from

Conversation

kernel-patches-daemon-bpf[bot]
Copy link

Pull request for series with
subject: sockmap: Fix reading with splice(2)
version: 3
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: ad97cb2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: ea2aecd
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: e860a98
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 1f48966
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 62ef449
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0768e98
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0768e98
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0ee30d9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0ee30d9
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: beb1097
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 42be23e
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 42be23e
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

vitkyrka added 2 commits July 21, 2025 17:39
The TCP BPF code will need to override splice_read(), so add it to prot.

Signed-off-by: Vincent Whitchurch <[email protected]>
If a socket is added to a sockmap with a verdict program which returns
SK_PASS, splice(2) is not able to read from the socket.

The verdict code removes skbs from the receive queue, checks them using
the bpf program, and then re-queues them onto a separate queue
(psock->ingress_msg).  The sockmap code modifies the TCP recvmsg hook to
check this second queue also so that works. But the splice_read hooks is
not modified and the default tcp_read_splice() only reads the normal
receive queue so it never sees the skbs which have been re-queued.

Fix it by using copy_splice_read() when replacing the proto for the
sockmap.  This could eventually be replaced with a more efficient custom
version.

Signed-off-by: Vincent Whitchurch <[email protected]>
@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 95993dc
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=980517
version: 3

vitkyrka added 3 commits July 21, 2025 17:39
If any tests failed, exit the program with a non-zero
error code.

Signed-off-by: Vincent Whitchurch <[email protected]>
Add an option to always return SK_PASS in the verdict callback
instead of redirecting the skb.  This allows testing cases
which are not covered by the test program as of now.

Signed-off-by: Vincent Whitchurch <[email protected]>
Add a test which checks that splice(2) is still able to read data from
the socket if it is added to a verdict program which returns SK_PASS.

Signed-off-by: Vincent Whitchurch <[email protected]>
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.

1 participant