From: Sun Jian <sun.jian.kdev@gmail.com>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, ast@kernel.org,
daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev,
davem@davemloft.net, kuba@kernel.org, hawk@kernel.org,
john.fastabend@gmail.com, sdf@fomichev.me, shuah@kernel.org,
jiayuan.chen@linux.dev, toke@redhat.com, menglong.dong@linux.dev,
emil@etsalapatis.com, Sun Jian <sun.jian.kdev@gmail.com>
Subject: [PATCH bpf v4 0/2] bpf: Fix generic devmap egress skb sharing
Date: Thu, 11 Jun 2026 16:08:47 +0800 [thread overview]
Message-ID: <20260611080850.536996-1-sun.jian.kdev@gmail.com> (raw)
Generic XDP devmap multi redirect can leave cloned skbs sharing packet
data. When a devmap egress program mutates packet data, another
destination sharing the same data may observe that mutation.
Fix this by making cloned skbs private before running the generic devmap
egress program. Add selftest coverage for the last-destination case,
where the final destination runs on the original skb while earlier
destinations use cloned skbs.
---
v4:
* Preserve mac_len after skb_copy().
* Separate errno return from XDP action output in
dev_map_bpf_prog_run_skb().
* Zero-initialize net_config in the new selftest.
v3: https://lore.kernel.org/bpf/20260611043317.512843-1-sun.jian.kdev@gmail.com/T/#m77fde65437b0398cb470649d4f1feeb85bc134bc
* Split the kernel fix and selftest into separate patches.
* Move the private-copy logic into dev_map_bpf_prog_run_skb().
* Use deterministic DEVMAP_HASH keys in the last-destination selftest.
* Fix the Fixes tag.
v2: https://lore.kernel.org/bpf/08c35c70-a59e-4e0e-91db-22b5ec30b611@linux.dev/T/#m613671b243e8651c47f84bb329f0ea668974c549
* Move the private-copy step into dev_map_generic_redirect() so the
last-destination path is covered as well.
* Use skb_copy() instead of skb_unshare() to keep caller ownership
unchanged on allocation failure.
* Add a generic XDP last-destination selftest case.
v1: https://lore.kernel.org/bpf/CABFUUZFimdrZdq=NWi+N-0sJZWvMwY=f4iF6-3TVMS8=m07Zmw@mail.gmail.com/
Sun Jian (2):
bpf: Run generic devmap egress prog on private skb
selftests/bpf: Cover generic devmap egress last-dst rewrite
kernel/bpf/devmap.c | 41 +++--
.../selftests/bpf/prog_tests/test_xdp_veth.c | 152 +++++++++++++++++-
2 files changed, 180 insertions(+), 13 deletions(-)
base-commit: e7ae89a0c97ce2b68b0983cd01eda67cf373517d
--
2.43.0
next reply other threads:[~2026-06-11 8:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 8:08 Sun Jian [this message]
2026-06-11 8:08 ` [PATCH bpf v4 1/2] bpf: Run generic devmap egress prog on private skb Sun Jian
2026-06-11 8:30 ` Toke Høiland-Jørgensen
2026-06-11 9:02 ` sun jian
2026-06-11 8:08 ` [PATCH bpf v4 2/2] selftests/bpf: Cover generic devmap egress last-dst rewrite Sun Jian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260611080850.536996-1-sun.jian.kdev@gmail.com \
--to=sun.jian.kdev@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=menglong.dong@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=toke@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox