All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vladimir Vdovin" <deliran@verdict.gg>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 5/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog
Date: Wed, 08 Jul 2026 20:45:34 +0000	[thread overview]
Message-ID: <20260708204535.0C85F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708203410.45121-6-deliran@verdict.gg>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Addition of fields to `struct xdp_meta` changes its size from 32 bytes to 44 bytes, causing an alignment-induced offset mismatch between 64-bit BPF programs and 32-bit userspace architectures.
--

--- Patch [5]: [PATCH bpf-next v4 5/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog ---
commit 1839c76747e10e7e5dc96d9eb03c1675cdf0e646
Author: Lorenzo Bianconi <lorenzo@kernel.org>

selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog

This patch introduces the capability to dump the HW rx checksum in the
xdp_hw_metadata program. It achieves this by using the new
bpf_xdp_metadata_rx_checksum() kfunc.

> diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h
> index bca09b94af261..f864d4a8bd8c6 100644
> --- a/tools/testing/selftests/bpf/xdp_metadata.h
> +++ b/tools/testing/selftests/bpf/xdp_metadata.h
[ ... ]
> @@ -52,10 +53,13 @@ struct xdp_meta {
>  		};
>  		__s32 rx_vlan_tag_err;
>  	};
> -	struct {
> -		__u32 ip_summed;
> -		__u32 cksum;
> -		__u8 cksum_level;
> +	union {
> +		struct {
> +			__u32 ip_summed;
> +			__u32 cksum;
> +			__u8 cksum_level;
> +		};
> +		__s32 rx_cksum_err;
>  	};
>  	enum xdp_meta_field hint_valid;
>  };

[Severity: Medium]
Does this change create an alignment mismatch between the 64-bit BPF program
and 32-bit userspace architectures?

The addition of these fields changes the size of struct xdp_meta to 44 bytes.
On a 32-bit x86 system, the __u64 fields earlier in the struct require only
4-byte alignment, keeping the userspace struct size at exactly 44 bytes.
However, the BPF program runs in a 64-bit context where __u64 requires 8-byte
alignment, causing the compiler to pad the struct to 48 bytes.

When verify_xdp_metadata() is called in userspace:

    meta = data - sizeof(*meta);

Userspace will subtract 44 bytes from the packet data pointer, while the
BPF program actually placed it at data - 48. Could this shift all metadata
reads by 4 bytes on 32-bit platforms, leading to incorrect results and
metadata corruption?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260708203410.45121-1-deliran@verdict.gg?part=5

  reply	other threads:[~2026-07-08 20:45 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-08 20:34 [PATCH bpf-next v4 0/6] Add the capability to load HW RX checksum in eBPF programs Vladimir Vdovin
2026-07-08 20:34 ` [Intel-wired-lan] " Vladimir Vdovin
2026-07-08 20:34 ` [PATCH bpf-next v4 1/6] netlink: specs: Add XDP RX checksum capability to XDP metadata specs Vladimir Vdovin
2026-07-08 20:34   ` [Intel-wired-lan] " Vladimir Vdovin
2026-07-08 20:43   ` sashiko-bot
2026-07-10 10:09   ` Loktionov, Aleksandr
2026-07-10 10:09     ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-07-10 19:05   ` Stanislav Fomichev
2026-07-10 19:05     ` [Intel-wired-lan] " Stanislav Fomichev
2026-07-08 20:34 ` [PATCH bpf-next v4 2/6] net: veth: Add xmo_rx_checksum callback to veth driver Vladimir Vdovin
2026-07-08 20:34   ` [Intel-wired-lan] " Vladimir Vdovin
2026-07-08 20:54   ` sashiko-bot
2026-07-10 10:09   ` Loktionov, Aleksandr
2026-07-10 10:09     ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 3/6] net: ice: Add xmo_rx_checksum callback Vladimir Vdovin
2026-07-08 20:34   ` [Intel-wired-lan] " Vladimir Vdovin
2026-07-08 20:43   ` sashiko-bot
2026-07-10 10:10   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-07-10 10:10     ` Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 4/6] selftests/bpf: Add selftest support for bpf_xdp_metadata_rx_checksum Vladimir Vdovin
2026-07-08 20:34   ` [Intel-wired-lan] " Vladimir Vdovin
2026-07-08 20:34 ` [PATCH bpf-next v4 5/6] selftests/bpf: Add bpf_xdp_metadata_rx_checksum support to xdp_hw_metadat prog Vladimir Vdovin
2026-07-08 20:34   ` [Intel-wired-lan] " Vladimir Vdovin
2026-07-08 20:45   ` sashiko-bot [this message]
2026-07-10 10:11   ` Loktionov, Aleksandr
2026-07-10 10:11     ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-07-08 20:34 ` [PATCH bpf-next v4 6/6] selftests: drv-net: add XDP RX checksum metadata tests Vladimir Vdovin
2026-07-08 20:34   ` [Intel-wired-lan] " Vladimir Vdovin
2026-07-08 20:41   ` sashiko-bot
2026-07-10 10:12   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-07-10 10:12     ` Loktionov, Aleksandr

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=20260708204535.0C85F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=deliran@verdict.gg \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.