Skip to content
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

bpf: a bug fix and test cases for bpf_skb_change_tail() #4722

Closed
wants to merge 4 commits into from

Conversation

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

Pull request for series with
subject: bpf: a bug fix and test cases for bpf_skb_change_tail()
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 3448ad2
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 537a252
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 537a252
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 537a252
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: d4c4435
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: bd74e23
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: bd74e23
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 5a6ea70
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: e2cf913
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: e2cf913
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 509df67
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 509df67
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

Cong Wang added 4 commits December 6, 2024 12:17
skb_network_offset() and skb_transport_offset() can be negative when
they are called after we pull the transport header, for example, when
we use eBPF sockmap at the point of ->sk_data_ready().

__bpf_skb_min_len() uses an unsigned int to get these offsets, this
leads to a very large number which then causes bpf_skb_change_tail()
failed unexpectedly.

Fix this by using a signed int to get these offsets and ensure the
minimum is at least zero.

Fixes: 5293efe ("bpf: add bpf_skb_change_tail helper")
Cc: John Fastabend <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
As requested by Daniel, we need to add a selftest to cover
bpf_skb_change_tail() cases in skb_verdict. Here we test trimming,
growing and error cases, and validate its expected return values and the
expected sizes of the payload.

Cc: John Fastabend <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Zijian Zhang <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Pull socket helpers out of sockmap_helpers.h so that they can be reused
for TC tests as well. This prepares for the next patch.

Cc: John Fastabend <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Zijian Zhang <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
Similarly to the previous test, we also need a test case to cover
positive offsets as well, TC is an excellent hook for this.

Cc: John Fastabend <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Zijian Zhang <[email protected]>
Signed-off-by: Cong Wang <[email protected]>
@kernel-patches-daemon-bpf-rc
Copy link
Author

Upstream branch: 509df67
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=913222
version: 2

@kernel-patches-daemon-bpf-rc
Copy link
Author

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=913222 expired. Closing PR.

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.

0 participants