BPF List
 help / color / mirror / Atom feed
From: Dominique Martinet <asmadeus@codewreck.org>
To: stable@vger.kernel.org, Alan Maguire <alan.maguire@oracle.com>,
	andrii@kernel.org, eddyz87@gmail.com
Cc: ast@kernel.org, ihor.solodrai@linux.dev, daniel@iogearbox.net,
	memxor@gmail.com, martin.lau@linux.dev, song@kernel.org,
	yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
	dwarves@vger.kernel.org, bpf@vger.kernel.org,
	Dominique Martinet <asmadeus@codewreck.org>
Subject: [PATCH 5.10-6.18] libbpf: fix cross-endian build with newer libbpf
Date: Mon, 16 Nov 2026 05:05:06 +0900	[thread overview]
Message-ID: <20261115200505.1494710-2-asmadeus@codewreck.org> (raw)

commit 087f3964f4b3 ("libbpf: Support layout section handling in BTF")
added extra data to the BTF header.

This extra data is ignored in the native case, but when building with
different endianness the bswap code in old libbpf would check for strict
size equality, leading to build failures such as this when BTF data is
generated with a newer version of libbpf (through pahole)
    BTFIDS  vmlinux.unstripped
  libbpf: Can't load BTF with non-native endianness due to unsupported header length 32
  FAILED: load BTF from vmlinux.unstripped: Operation not supported
  make[2]: *** [../scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 255

Newer libbpf versions also properly ignore trailing data in the bswap
case, but the patch is too intrusive to backport, just fix the header
length comparison.

Link: https://github.com/NixOS/nixpkgs/pull/570639
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
---
Hey,

we've got a cross build failure report for ppc64 in nixpkgs (link in
commit message), that turned out as described above.
(build broke for all kernels before 7.1)

In this case I believe it's easier to just fix the check than backport
the full layout section handling support, is that ok?
I've confirmed the build succeeds with this, I assume the reporter will
eventually also boot check but from my understanding of the code this
should be fine.

Feel free to throw this away if there's a better way, just let me know
if I can help.

Thanks

 tools/lib/bpf/btf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 9f141395c074..ae344cf58e85 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -236,7 +236,7 @@ static int btf_parse_hdr(struct btf *btf)
 
 	if (hdr->magic == bswap_16(BTF_MAGIC)) {
 		btf->swapped_endian = true;
-		if (bswap_32(hdr->hdr_len) != sizeof(struct btf_header)) {
+		if (bswap_32(hdr->hdr_len) < sizeof(struct btf_header)) {
 			pr_warn("Can't load BTF with non-native endianness due to unsupported header length %u\n",
 				bswap_32(hdr->hdr_len));
 			return -ENOTSUP;
-- 
2.56.1


             reply	other threads:[~2026-11-15 20:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-15 20:05 Dominique Martinet [this message]
2026-11-15 20:23 ` [PATCH 5.10-6.18] libbpf: fix cross-endian build with newer libbpf sashiko-bot
2026-11-15 20:41   ` Dominique Martinet

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=20261115200505.1494710-2-asmadeus@codewreck.org \
    --to=asmadeus@codewreck.org \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dwarves@vger.kernel.org \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=jolsa@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=song@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=yonghong.song@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