<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/lib/bpf/relo_core.c, branch master</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=master</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2025-10-01T22:27:25Z</updated>
<entry>
<title>libbpf: move libbpf_errstr() into libbpf_utils.c</title>
<updated>2025-10-01T22:27:25Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2025-10-01T17:13:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c68b6fdc3600466e3c265bad34d099eb8c5280f1'/>
<id>urn:sha1:c68b6fdc3600466e3c265bad34d099eb8c5280f1</id>
<content type='text'>
Get rid of str_err.{c,h} by moving implementation of libbpf_errstr()
into libbpf_utils.c and declarations into libbpf_internal.h.

Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/r/20251001171326.3883055-4-andrii@kernel.org
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Eduard Zingerman &lt;eddyz87@gmail.com&gt;
</content>
</entry>
<entry>
<title>libbpf: fix LDX/STX/ST CO-RE relocation size adjustment logic</title>
<updated>2025-02-15T03:58:05Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2025-02-07T01:48:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=06096d19ee3897a7e70922580159607fe315da7a'/>
<id>urn:sha1:06096d19ee3897a7e70922580159607fe315da7a</id>
<content type='text'>
Libbpf has a somewhat obscure feature of automatically adjusting the
"size" of LDX/STX/ST instruction (memory store and load instructions),
based on originally recorded access size (u8, u16, u32, or u64) and the
actual size of the field on target kernel. This is meant to facilitate
using BPF CO-RE on 32-bit architectures (pointers are always 64-bit in
BPF, but host kernel's BTF will have it as 32-bit type), as well as
generally supporting safe type changes (unsigned integer type changes
can be transparently "relocated").

One issue that surfaced only now, 5 years after this logic was
implemented, is how this all works when dealing with fields that are
arrays. This isn't all that easy and straightforward to hit (see
selftests that reproduce this condition), but one of sched_ext BPF
programs did hit it with innocent looking loop.

Long story short, libbpf used to calculate entire array size, instead of
making sure to only calculate array's element size. But it's the element
that is loaded by LDX/STX/ST instructions (1, 2, 4, or 8 bytes), so
that's what libbpf should check. This patch adjusts the logic for
arrays and fixed the issue.

Reported-by: Emil Tsalapatis &lt;emil@etsalapatis.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Eduard Zingerman &lt;eddyz87@gmail.com&gt;
Link: https://lore.kernel.org/r/20250207014809.1573841-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Improve log message formatting</title>
<updated>2024-10-04T00:47:36Z</updated>
<author>
<name>Tony Ambardar</name>
</author>
<published>2024-09-16T08:37:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e8957c0dde3c945db2403beb3131a5ad84860b5f'/>
<id>urn:sha1:e8957c0dde3c945db2403beb3131a5ad84860b5f</id>
<content type='text'>
Fix missing newlines and extraneous terminal spaces in messages.

Signed-off-by: Tony Ambardar &lt;tony.ambardar@gmail.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/086884b7cbf87e524d584f9bf87f7a580e378b2b.1726475448.git.tony.ambardar@gmail.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: fix signedness determination in CO-RE relo handling logic</title>
<updated>2023-08-24T04:13:48Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2023-08-24T00:00:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f3bdb54f09ab4cdbca48bf7befa8997cadd8d6a1'/>
<id>urn:sha1:f3bdb54f09ab4cdbca48bf7befa8997cadd8d6a1</id>
<content type='text'>
Extracting btf_int_encoding() is only meaningful for BTF_KIND_INT, so we
need to check that first before inferring signedness.

Closes: https://github.com/libbpf/libbpf/issues/704
Reported-by: Lorenz Bauer &lt;lmb@isovalent.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Yonghong Song &lt;yonghong.song@linux.dev&gt;
Link: https://lore.kernel.org/r/20230824000016.2658017-2-andrii@kernel.org
Signed-off-by: Martin KaFai Lau &lt;martin.lau@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Remove several dead assignments</title>
<updated>2023-03-01T19:13:11Z</updated>
<author>
<name>Viktor Malik</name>
</author>
<published>2023-03-01T08:53:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=7832d06bd9f9080d9ceae388bb81bf33adce3850'/>
<id>urn:sha1:7832d06bd9f9080d9ceae388bb81bf33adce3850</id>
<content type='text'>
Clang Static Analyzer (scan-build) reports several dead assignments in
libbpf where the assigned value is unconditionally overridden by another
value before it is read. Remove these assignments.

Signed-off-by: Viktor Malik &lt;vmalik@redhat.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/5503d18966583e55158471ebbb2f67374b11bf5e.1677658777.git.vmalik@redhat.com
</content>
</entry>
<entry>
<title>bpf: Correctly propagate errors up from bpf_core_composites_match</title>
<updated>2022-07-08T22:31:43Z</updated>
<author>
<name>Daniel Müller</name>
</author>
<published>2022-07-07T21:19:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=06cd4e9d5d969d713e6b710f0e5ca0bc8476ae41'/>
<id>urn:sha1:06cd4e9d5d969d713e6b710f0e5ca0bc8476ae41</id>
<content type='text'>
This change addresses a comment made earlier [0] about a missing return
of an error when __bpf_core_types_match is invoked from
bpf_core_composites_match, which could have let to us erroneously
ignoring errors.

Regarding the typedef name check pointed out in the same context, it is
not actually an issue, because callers of the function perform a name
check for the root type anyway. To make that more obvious, let's add
comments to the function (similar to what we have for
bpf_core_types_are_compat, which is called in pretty much the same
context).

[0]: https://lore.kernel.org/bpf/165708121449.4919.13204634393477172905.git-patchwork-notify@kernel.org/T/#m55141e8f8cfd2e8d97e65328fa04852870d01af6

Suggested-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Daniel Müller &lt;deso@posteo.net&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220707211931.3415440-1-deso@posteo.net
</content>
</entry>
<entry>
<title>bpf, libbpf: Add type match support</title>
<updated>2022-07-06T04:14:25Z</updated>
<author>
<name>Daniel Müller</name>
</author>
<published>2022-06-28T16:01:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ec6209c8d42f815bc3bef10934637ca92114cd1b'/>
<id>urn:sha1:ec6209c8d42f815bc3bef10934637ca92114cd1b</id>
<content type='text'>
This patch adds support for the proposed type match relation to
relo_core where it is shared between userspace and kernel. It plumbs
through both kernel-side and libbpf-side support.

The matching relation is defined as follows (copy from source):
- modifiers and typedefs are stripped (and, hence, effectively ignored)
- generally speaking types need to be of same kind (struct vs. struct, union
  vs. union, etc.)
  - exceptions are struct/union behind a pointer which could also match a
    forward declaration of a struct or union, respectively, and enum vs.
    enum64 (see below)
Then, depending on type:
- integers:
  - match if size and signedness match
- arrays &amp; pointers:
  - target types are recursively matched
- structs &amp; unions:
  - local members need to exist in target with the same name
  - for each member we recursively check match unless it is already behind a
    pointer, in which case we only check matching names and compatible kind
- enums:
  - local variants have to have a match in target by symbolic name (but not
    numeric value)
  - size has to match (but enum may match enum64 and vice versa)
- function pointers:
  - number and position of arguments in local type has to match target
  - for each argument and the return value we recursively check match

Signed-off-by: Daniel Müller &lt;deso@posteo.net&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220628160127.607834-5-deso@posteo.net
</content>
</entry>
<entry>
<title>bpf: Merge "types_are_compat" logic into relo_core.c</title>
<updated>2022-06-24T21:15:37Z</updated>
<author>
<name>Daniel Müller</name>
</author>
<published>2022-06-23T18:29:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=fd75733da2f376c0c8c6513c3cb2ac227082ec5c'/>
<id>urn:sha1:fd75733da2f376c0c8c6513c3cb2ac227082ec5c</id>
<content type='text'>
BPF type compatibility checks (bpf_core_types_are_compat()) are
currently duplicated between kernel and user space. That's a historical
artifact more than intentional doing and can lead to subtle bugs where
one implementation is adjusted but another is forgotten.

That happened with the enum64 work, for example, where the libbpf side
was changed (commit 23b2a3a8f63a ("libbpf: Add enum64 relocation
support")) to use the btf_kind_core_compat() helper function but the
kernel side was not (commit 6089fb325cf7 ("bpf: Add btf enum64
support")).

This patch addresses both the duplication issue, by merging both
implementations and moving them into relo_core.c, and fixes the alluded
to kind check (by giving preference to libbpf's already adjusted logic).

For discussion of the topic, please refer to:
https://lore.kernel.org/bpf/CAADnVQKbWR7oarBdewgOBZUPzryhRYvEbkhyPJQHHuxq=0K1gw@mail.gmail.com/T/#mcc99f4a33ad9a322afaf1b9276fb1f0b7add9665

Changelog:
v1 -&gt; v2:
- limited libbpf recursion limit to 32
- changed name to __bpf_core_types_are_compat
- included warning previously present in libbpf version
- merged kernel and user space changes into a single patch

Signed-off-by: Daniel Müller &lt;deso@posteo.net&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20220623182934.2582827-1-deso@posteo.net
</content>
</entry>
<entry>
<title>libbpf: Add enum64 relocation support</title>
<updated>2022-06-07T17:20:43Z</updated>
<author>
<name>Yonghong Song</name>
</author>
<published>2022-06-07T06:26:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=23b2a3a8f63a9dc14ad0c7a63098e0b3575b1173'/>
<id>urn:sha1:23b2a3a8f63a9dc14ad0c7a63098e0b3575b1173</id>
<content type='text'>
The enum64 relocation support is added. The bpf local type
could be either enum or enum64 and the remote type could be
either enum or enum64 too. The all combinations of local enum/enum64
and remote enum/enum64 are supported.

Acked-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/r/20220607062647.3721719-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Fix an error in 64bit relocation value computation</title>
<updated>2022-06-07T17:20:42Z</updated>
<author>
<name>Yonghong Song</name>
</author>
<published>2022-06-07T06:26:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b58b2b3a31228bd9aaed9b96e9452dafd0d46024'/>
<id>urn:sha1:b58b2b3a31228bd9aaed9b96e9452dafd0d46024</id>
<content type='text'>
Currently, the 64bit relocation value in the instruction
is computed as follows:
  __u64 imm = insn[0].imm + ((__u64)insn[1].imm &lt;&lt; 32)

Suppose insn[0].imm = -1 (0xffffffff) and insn[1].imm = 1.
With the above computation, insn[0].imm will first sign-extend
to 64bit -1 (0xffffffffFFFFFFFF) and then add 0x1FFFFFFFF,
producing incorrect value 0xFFFFFFFF. The correct value
should be 0x1FFFFFFFF.

Changing insn[0].imm to __u32 first will prevent 64bit sign
extension and fix the issue. Merging high and low 32bit values
also changed from '+' to '|' to be consistent with other
similar occurences in kernel and libbpf.

Acked-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Dave Marchevsky &lt;davemarchevsky@fb.com&gt;
Signed-off-by: Yonghong Song &lt;yhs@fb.com&gt;
Link: https://lore.kernel.org/r/20220607062610.3717378-1-yhs@fb.com
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
</feed>
