SHA256
8
0
forked from pool/libbpf

4 Commits

5 changed files with 52 additions and 77 deletions

View File

@@ -1,67 +0,0 @@
From 1f7c2f78d74e239ee4fce03f9a858062ae3d5512 Mon Sep 17 00:00:00 2001
From: Alan Maguire <alan.maguire@oracle.com>
Date: Tue, 29 Apr 2025 17:10:42 +0100
Subject: [PATCH 1/1] libbpf: Add identical pointer detection to
btf_dedup_is_equiv()
Recently as a side-effect of
commit ac053946f5c4 ("compiler.h: introduce TYPEOF_UNQUAL() macro")
issues were observed in deduplication between modules and kernel BTF
such that a large number of kernel types were not deduplicated so
were found in module BTF (task_struct, bpf_prog etc). The root cause
appeared to be a failure to dedup struct types, specifically those
with members that were pointers with __percpu annotations.
The issue in dedup is at the point that we are deduplicating structures,
we have not yet deduplicated reference types like pointers. If multiple
copies of a pointer point at the same (deduplicated) integer as in this
case, we do not see them as identical. Special handling already exists
to deal with structures and arrays, so add pointer handling here too.
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250429161042.2069678-1-alan.maguire@oracle.com
---
src/btf.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/btf.c b/src/btf.c
index e9673c0..c7df63d 100644
--- a/src/btf.c
+++ b/src/btf.c
@@ -4337,6 +4337,19 @@ static bool btf_dedup_identical_structs(struct btf_dedup *d, __u32 id1, __u32 id
return true;
}
+static bool btf_dedup_identical_ptrs(struct btf_dedup *d, __u32 id1, __u32 id2)
+{
+ struct btf_type *t1, *t2;
+
+ t1 = btf_type_by_id(d->btf, id1);
+ t2 = btf_type_by_id(d->btf, id2);
+
+ if (!btf_is_ptr(t1) || !btf_is_ptr(t2))
+ return false;
+
+ return t1->type == t2->type;
+}
+
/*
* Check equivalence of BTF type graph formed by candidate struct/union (we'll
* call it "candidate graph" in this description for brevity) to a type graph
@@ -4469,6 +4482,9 @@ static int btf_dedup_is_equiv(struct btf_dedup *d, __u32 cand_id,
*/
if (btf_dedup_identical_structs(d, hypot_type_id, cand_id))
return 1;
+ /* A similar case is again observed for PTRs. */
+ if (btf_dedup_identical_ptrs(d, hypot_type_id, cand_id))
+ return 1;
return 0;
}
--
2.49.0

Binary file not shown.

3
libbpf-1.6.2.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:16f31349c70764cba8e0fad3725cc9f52f6cf952554326aa0229daaa21ef4fbd
size 1045487

View File

@@ -1,8 +1,50 @@
-------------------------------------------------------------------
Mon Aug 25 19:09:42 UTC 2025 - Andreas Stieger <andreas.stieger@gmx.de>
- update to 1.6.2:
* add proper LIBBPF_API annotation to bpf_object__prepare() API,
to make it usable in shared library mode
* small fix up to better handle DEVMAP/DEVMAP_HASH maps
-------------------------------------------------------------------
Mon Jul 21 03:31:14 UTC 2025 - Shung-Hsi Yu <shung-hsi.yu@suse.com>
- update to 1.6.0:
* add more control over BPF object lifetime with new preparation step
(bpf_object__prepare() API)
* libbpf will report symbolic error code (e.g., "-EINVAL") in addition to
human-readable error description
* bpf_prog_stream_read() API
* BPF token support when attaching BPF trampoline-based BPF programs in
bpf_program__set_attach_target()
* BPF token support for BPF_BTF_GET_FD_BY_ID command
* support multi-uprobe session (SEC("uprobe.session")) BPF programs
* support unique_match option for multi-kprobe attachment
* support creating and destroying qdisk with BPF_TC_QDISC flag;
* bpf_program__attach_cgroup_opts() which enables more precise cgroup-based
attachment ordering
* automatically take advantage of memory-mappable kernel BTF
(/sys/kernel/btf/vmlinux), if supported
* emit_strings option for BTF dumper API, improving string-like data printing
* add BPF program's func and line info accessors
* BPF linker supports linking ELF object files coming from memory buffer and
referenced by FD, in addition to file path-based APIs;
* small improvements to BTF dedup to handle rare quirky corner cases produces
by some compilers
* add likely() and unlikely() convenience macros;
* __arg_untrusted annotation for BPF global subprog arguments;
* bpf_stream_printk() macro for working with BPF streams;
* bpf_usdt_arg_size() API
- update to 1.6.1:
* fixing a possible crash when handling BPF arena global variable relocations
- drop 0001-libbpf-Add-identical-pointer-detection-to-btf_dedup_.patch, which
is now included
-------------------------------------------------------------------
Thu Jun 5 14:34:05 UTC 2025 - Shung-Hsi Yu <shung-hsi.yu@suse.com>
- Workaround kernel module size increase due to BTF deduplication
issue since the introduction of TYPEOF_UNQUAL (poo#183503)
issue since the introduction of TYPEOF_UNQUAL (poo#183503 bsc#1244135)
* add 0001-libbpf-Add-identical-pointer-detection-to-btf_dedup_.patch
-------------------------------------------------------------------

View File

@@ -2,6 +2,7 @@
# spec file for package libbpf
#
# Copyright (c) 2025 SUSE LLC
# Copyright (c) 2025 Andreas Stieger <Andreas.Stieger@gmx.de>
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -19,14 +20,13 @@
%define sover_major 1
%define libname libbpf%{sover_major}
Name: libbpf
Version: 1.5.1
Version: 1.6.2
Release: 0
Summary: C library for managing eBPF programs and maps
License: LGPL-2.1-only
URL: https://github.com/libbpf/libbpf
Source: https://github.com/libbpf/libbpf/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
Source99: baselibs.conf
Patch0: 0001-libbpf-Add-identical-pointer-detection-to-btf_dedup_.patch
BuildRequires: libelf-devel
BuildRequires: linux-glibc-devel >= 4.5
BuildRequires: zlib-devel
@@ -61,17 +61,17 @@ libbpf is a C library which provides API for managing eBPF programs and maps.
%build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects
cd src
%make_build V=1 CFLAGS="%{optflags}"
%make_build CFLAGS="%{optflags}"
%install
cd src
%make_install V=1
%post -n %{libname} -p /sbin/ldconfig
%postun -n %{libname} -p /sbin/ldconfig
%ldconfig_scriptlets -n %{libname}
%files -n %{libname}
%{_libdir}/%{name}.so.%{sover_major}*
%license LICENSE LICENSE.BSD-2-Clause LICENSE.LGPL-2.1
%{_libdir}/%{name}.so.%{sover_major}{,.*}
%files devel
%license LICENSE LICENSE.BSD-2-Clause LICENSE.LGPL-2.1