BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Borkmann" <daniel@iogearbox.net>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v4 7/9] selftests/bpf: Adjust bpf_map layout in verifier_map_ptr
Date: Mon, 06 Jul 2026 14:27:39 +0000	[thread overview]
Message-ID: <20260706142740.1777F1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260706135644.326006-8-daniel@iogearbox.net>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Critical] The removal of the `excl` field from `struct bpf_map` breaks backwards compatibility for existing, previously compiled userspace signed BPF loaders (light skeletons).
--

commit c88125fac4570eca959a997d221adcd929990142
Author: Daniel Borkmann <daniel@iogearbox.net>

selftests/bpf: Adjust bpf_map layout in verifier_map_ptr

This commit updates the verifier_map_ptr selftest to reflect the new layout
of struct bpf_map. It adjusts the offsets and expected error messages to
account for the ops pointer moving to offset 32 after the removal of the
excl field.

> diff --git a/tools/testing/selftests/bpf/progs/verifier_map_ptr.c b/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
> index 1661936598703..e0a65835c861b 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_map_ptr.c
> @@ -72,14 +72,15 @@ __naked void bpf_map_ptr_write_rejected(void)
>  
>  /*
> - * struct bpf_map starts with the SHA256 hash sha[32] at offset 0 (a readable
> - * byte array), the u32 excl field at offset 32, and the ops pointer at offset
> - * 40. Reading a u32 at offset 41 reaches into the middle of the ops pointer,
> - * i.e. a partial pointer access, which is rejected.
> + * struct bpf_map starts with the SHA256 hash sha[32] at offset 0 (a readable
> + * byte array), followed by the ops pointer at offset 32 and the inner_map_meta
> + * pointer at offset 40. Reading a u32 at offset 41 reaches into the middle of
> + * the inner_map_meta pointer, i.e. a partial pointer access, which is
> + * rejected.
>   */
[Severity: Critical]
Does this structure layout change introduce a regression by breaking backwards
compatibility for existing userspace signed BPF loaders (light skeletons)?

Older versions of bpftool generated a loader program that included explicit
BPF bytecode to verify the metadata map via a 4-byte read of the excl field
at offset 32. To support this, the kernel previously pinned this offset using
BUILD_BUG_ON(offsetof(struct bpf_map, excl) != SHA256_DIGEST_SIZE).

By removing excl without retaining 4 bytes of padding, the 8-byte ops pointer
shifts to offset 32 in struct bpf_map. When an old loader attempts to read 4
bytes at offset 32, the verifier sees a partial pointer read (since 8 != 4)
and unconditionally rejects it:

kernel/bpf/btf.c:btf_struct_access() {
    ...
    if (msize != size || off != moff) {
        bpf_log(log,
            "cannot access ptr member %s with moff %u in struct %s with off %u size %u\n",
            mname, moff, tname, off, size);
        return -EACCES;
    }
    ...
}

Could a 4-byte padding be added to maintain backward compatibility, allowing
old loaders to safely read the padding while the new kernel securely handles
the load-time verification?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260706135644.326006-1-daniel@iogearbox.net?part=7

  reply	other threads:[~2026-07-06 14:27 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 13:56 [PATCH bpf-next v4 0/9] Verify BPF signed loader at load time Daniel Borkmann
2026-07-06 13:56 ` [PATCH bpf-next v4 1/9] bpf: Resolve and cache fd_array objects " Daniel Borkmann
2026-07-06 15:42   ` Anton Protopopov
2026-07-06 13:56 ` [PATCH bpf-next v4 2/9] bpf: Move bigger allocations below fd_array resolution Daniel Borkmann
2026-07-06 14:21   ` sashiko-bot
2026-07-06 13:56 ` [PATCH bpf-next v4 3/9] bpf: Verify signed loader metadata at load time Daniel Borkmann
2026-07-06 14:26   ` sashiko-bot
2026-07-06 14:48     ` Daniel Borkmann
2026-07-06 15:09   ` bot+bpf-ci
2026-07-06 17:16   ` Paul Moore
2026-07-06 13:56 ` [PATCH bpf-next v4 4/9] libbpf: Drop in-loader metadata check for load-time verification Daniel Borkmann
2026-07-06 14:50   ` bot+bpf-ci
2026-07-06 13:56 ` [PATCH bpf-next v4 5/9] bpftool: Check EVP_Digest when computing excl_prog_hash Daniel Borkmann
2026-07-06 13:56 ` [PATCH bpf-next v4 6/9] bpftool: Cover loader metadata with the program signature Daniel Borkmann
2026-07-06 13:56 ` [PATCH bpf-next v4 7/9] selftests/bpf: Adjust bpf_map layout in verifier_map_ptr Daniel Borkmann
2026-07-06 14:27   ` sashiko-bot [this message]
2026-07-06 14:30     ` Daniel Borkmann
2026-07-06 13:56 ` [PATCH bpf-next v4 8/9] selftests/bpf: Verify load-time signed loader metadata Daniel Borkmann
2026-07-06 13:56 ` [PATCH bpf-next v4 9/9] Documentation/bpf: Add BPF signing and enforcement doc Daniel Borkmann
2026-07-06 17:13 ` [PATCH bpf-next v4 0/9] Verify BPF signed loader at load time Paul Moore
2026-07-06 17:47   ` Daniel Borkmann
2026-07-06 19:20     ` Paul Moore

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=20260706142740.1777F1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --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