From: sashiko-bot@kernel.org
To: "Jiayuan Chen" <jiayuan.chen@linux.dev>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf v3 2/2] selftests/bpf: add xdp_shrink_frags
Date: Fri, 11 Sep 2026 14:46:31 +0000 [thread overview]
Message-ID: <20260911144631.A7A4C1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911135711.109338-3-jiayuan.chen@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Type punning a byte array into a struct pointer violates strict aliasing rules.
--
commit 7d6829eaaf619b188a1baf1e3f7bf91fc5a0a765
Author: Jiayuan Chen <jiayuan.chen@linux.dev>
selftests/bpf: add xdp_shrink_frags
This commit adds a BPF selftest for XDP that shrinks fragments and
triggers a page_pool leak on a generic XDP path. The test exercises
test_tun, test_veth, and test_veth_tx to cover different data path
behaviors on 4K pages.
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_shrink_frags.c b/tools/testing/selftests/bpf/prog_tests/xdp_shrink_frags.c
> new file mode 100644
> index 0000000000000..ee8f9034a2684
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_shrink_frags.c
[ ... ]
> +static void test_tun(struct xdp_shrink_frags *skel)
> +{
> + __u8 head[74], frag1[2048], frag2[2048];
> + struct ethhdr *eth = (void *)head;
> + int tap_fd = -1, ifindex, err;
> + struct netns_obj *ns = NULL;
> + struct iovec iov[3];
> + ssize_t n;
[ ... ]
> + memset(head, 0, sizeof(head));
> + memset(frag1, 0x41, sizeof(frag1));
> + memset(frag2, 0x42, sizeof(frag2));
> + eth->h_proto = htons(ETH_P_IP);
[Severity: Medium]
Does this code violate strict aliasing rules by type-punning a byte array
into a struct pointer?
When test_tun() executes, it accesses an object declared as an array of
characters (__u8) through an unrelated larger struct pointer (struct ethhdr *).
Since this code is located in a test program running in user space (under
tools/), standard -fstrict-aliasing rules apply.
Could the compiler assume that eth does not alias head, leading it to reorder
or drop the write to eth->h_proto entirely during optimization?
> +
> + iov[0].iov_base = head; iov[0].iov_len = sizeof(head);
> + iov[1].iov_base = frag1; iov[1].iov_len = sizeof(frag1);
> + iov[2].iov_base = frag2; iov[2].iov_len = sizeof(frag2);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911135711.109338-1-jiayuan.chen@linux.dev?part=2
next prev parent reply other threads:[~2026-09-11 14:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 13:56 [PATCH bpf v3 0/2] net: xdp: fix bpf_xdp_shrink_data() page handling on generic XDP and veth Jiayuan Chen
2026-09-11 13:56 ` [PATCH bpf v3 1/2] bpf, veth: xdp: fix page_pool page leak on skb-backed XDP Jiayuan Chen
2026-09-11 14:36 ` sashiko-bot
2026-09-12 2:28 ` Jiayuan Chen
2026-09-13 13:05 ` Lorenzo Bianconi
2026-09-11 13:56 ` [PATCH bpf v3 2/2] selftests/bpf: add xdp_shrink_frags Jiayuan Chen
2026-09-11 14:46 ` sashiko-bot [this message]
2026-09-12 2:34 ` Jiayuan Chen
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=20260911144631.A7A4C1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/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