Skip to content

bpf: Run generic devmap egress prog on private skb#8032

Open
kernel-patches-daemon-bpf-rc[bot] wants to merge 1 commit into
bpf_basefrom
series/1109185=>bpf
Open

bpf: Run generic devmap egress prog on private skb#8032
kernel-patches-daemon-bpf-rc[bot] wants to merge 1 commit into
bpf_basefrom
series/1109185=>bpf

Conversation

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown

Pull request for series with
subject: bpf: Run generic devmap egress prog on private skb
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1109185

@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

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

Generic XDP devmap multi redirect uses skb_clone() for the
intermediate destinations and sends the last destination with the
original skb. This can leave multiple destinations sharing the same
packet data.

This becomes visible when a devmap egress program mutates packet data.
One destination can observe changes made for another destination. The
last-destination path has the same problem: the last destination runs on
the original skb, so its egress program can modify packet data still
shared with earlier cloned skbs.

Native XDP broadcast redirect does not have this issue because
xdpf_clone() copies the frame data for each destination. Generic XDP
should provide the same per-destination isolation before running a
devmap egress program.

Fix this by making cloned skbs private in dev_map_generic_redirect()
before running the devmap egress program. Use skb_copy() instead of
skb_unshare() so that allocation failure does not consume the skb and
the existing caller error paths keep their ownership semantics.

Add a selftest that covers the last-destination case where earlier
destinations do not have a devmap egress program, while the final
destination does.

Tested with:
  ./test_progs -t xdp_veth_egress
  ./test_progs -t xdp_veth
  ./test_progs -t xdp

Fixes: e624d4e ("xdp: Extend xdp_redirect_map with broadcast support")
Suggested-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Sun Jian <sun.jian.kdev@gmail.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@redhat.com>
@kernel-patches-daemon-bpf-rc

Copy link
Copy Markdown
Author

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

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