Skip to content

bpf, xdp: clean adjust_{head,meta} memory when offset < 0 #8725

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

Closed
wants to merge 2 commits into from

Conversation

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

Pull request for series with
subject: bpf, xdp: clean adjust_{head,meta} memory when offset < 0
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 8be3a12
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 07be1f6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 07be1f6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 07be1f6
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0c2623c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 0c2623c
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 3f8ad18
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

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

@kernel-patches-daemon-bpf
Copy link
Author

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

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 06a2236
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

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

@kernel-patches-daemon-bpf
Copy link
Author

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

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 9f867ba
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 9bae8f4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

@kernel-patches-daemon-bpf
Copy link
Author

Upstream branch: 9bae8f4
series: https://patchwork.kernel.org/project/netdevbpf/list/?series=948419
version: 2

mrpre added 2 commits April 7, 2025 09:23
The device allocates an skb, it additionally allocates a prepad size
(usually equal to NET_SKB_PAD or XDP_PACKET_HEADROOM) but leaves it
uninitialized.

The bpf_xdp_adjust_head function moves skb->data forward, which allows
users to access data belonging to other programs, posing a security risk.

Reported-by: [email protected]
Closes: https://lore.kernel.org/all/[email protected]/T/
Signed-off-by: Jiayuan Chen <[email protected]>
We added a memset operation during the adjust operation, which may cause
performance issues.

Therefore, we added perf testing, and testing found that for common header
length operations, memset() operation increased the performance overhead
by 2ns, which is negligible for the net stack.

Before memset
./test_progs -a xdp_adjust_head_perf -v
run adjust head with size 6 cost 56 ns
run adjust head with size 20 cost 56 ns
run adjust head with size 40 cost 56 ns
run adjust head with size 200 cost 56 ns

After memset
./test_progs -a xdp_adjust_head_perf -v
run adjust head with size 6 cost 58 ns
run adjust head with size 20 cost 58 ns
run adjust head with size 40 cost 58 ns
run adjust head with size 200 cost 66 ns

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

At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=948419 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.

1 participant