BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Siddharth C" <siddharthcibi@icloud.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests/bpf: validate rx_queue_index in xdp_metadata
Date: Sat, 20 Jun 2026 12:36:50 +0000	[thread overview]
Message-ID: <20260620123650.B20DA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260620121321.45227-3-siddharthcibi@icloud.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Adding `rx_queue_index` changes `struct xdp_meta` size to 36 bytes, causing implicit padding to 40 bytes on 64-bit systems but not on 32-bit systems. This creates a BPF-to-userspace metadata offset mismatch on 32-bit hosts.
- [Low] The newly added assertion returns directly with incorrect space-based indentation.
--

commit 5d50c9ea90d4f7a83d1f9562df723456d7ed8e43
Author: Siddharth_Cibi <siddharthcibi@icloud.com>

selftests/bpf: validate rx_queue_index in xdp_metadata

This commit extends the xdp_metadata selftest to capture and validate
the rx_queue_index field. It adds the index to the xdp_meta structure and
asserts its value matches the expected queue during packet verification.

> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c
> @@ -309,7 +309,8 @@ static int verify_xsk_metadata(struct xsk *xsk, bool sent_from_af_xdp)
>  
>  	if (!ASSERT_NEQ(meta->rx_hash, 0, "rx_hash"))
>  		return -1;
> -
> +	if (!ASSERT_EQ(meta->rx_queue_index, QUEUE_ID, "rx_queue_index"))
> +        	return -1;

[Severity: Low]
This isn't a bug, but does this return statement use spaces for indentation
instead of tabs?

[ ... ]

> diff --git a/tools/testing/selftests/bpf/xdp_metadata.h b/tools/testing/selftests/bpf/xdp_metadata.h
> --- a/tools/testing/selftests/bpf/xdp_metadata.h
> +++ b/tools/testing/selftests/bpf/xdp_metadata.h
> @@ -49,4 +49,5 @@ struct xdp_meta {
>  		__s32 rx_vlan_tag_err;
>  	};
>  	enum xdp_meta_field hint_valid;
> +	__u32 rx_queue_index;
>  };

[Severity: Medium]
Does adding rx_queue_index cause a structure size mismatch between the BPF
target and 32-bit hosts?

The xdp_meta struct contains __u64 fields, so on the BPF target and 64-bit
hosts, the 36-byte structure will be padded to 40 bytes to maintain 8-byte
alignment. In the BPF program, bpf_xdp_adjust_meta() will then allocate 40
bytes.

However, on 32-bit hosts where __u64 only requires 4-byte alignment, the
compiler will evaluate the structure size as 36 bytes. The userspace test
then reads the metadata pointer exactly 4 bytes after the start of the
BPF-populated metadata, leading to misaligned reads for all fields.

Should an explicit 4-byte padding field be added at the end of the struct,
or an explicit alignment attribute be used?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260620121321.45227-1-siddharthcibi@icloud.com?part=2

  reply	other threads:[~2026-06-20 12:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-20 12:13 Siddharth C
2026-06-20 12:13 ` [PATCH 1/2] bpf: preserve rx_queue_index across XDP redirects Siddharth C
2026-06-20 12:31   ` sashiko-bot
2026-06-20 12:13 ` [PATCH 2/2] selftests/bpf: validate rx_queue_index in xdp_metadata Siddharth C
2026-06-20 12:36   ` sashiko-bot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-06-19 19:57 Siddharth_Cibi
2026-06-19 19:57 ` [PATCH 2/2] selftests/bpf: validate rx_queue_index in xdp_metadata Siddharth_Cibi
2026-06-19 20:07   ` sashiko-bot
2026-06-19 20:50   ` bot+bpf-ci

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=20260620123650.B20DA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=siddharthcibi@icloud.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