<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/tools/lib/bpf, branch v6.13.2</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.13.2</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.13.2'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2025-02-08T09:01:39+00:00</updated>
<entry>
<title>libbpf: Fix incorrect traversal end type ID when marking BTF_IS_EMBEDDED</title>
<updated>2025-02-08T09:01:39+00:00</updated>
<author>
<name>Pu Lehui</name>
<email>pulehui@huawei.com</email>
</author>
<published>2025-01-15T10:02:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=9e59b09a0a3e90ad13dcea3e26b94bd2122ad2a0'/>
<id>urn:sha1:9e59b09a0a3e90ad13dcea3e26b94bd2122ad2a0</id>
<content type='text'>
[ Upstream commit 5ca681a86ef93369685cb63f71994f4cf7303e7c ]

When redirecting the split BTF to the vmlinux base BTF, we need to mark
the distilled base struct/union members of split BTF structs/unions in
id_map with BTF_IS_EMBEDDED. This indicates that these types must match
both name and size later. Therefore, we need to traverse the entire
split BTF, which involves traversing type IDs from nr_dist_base_types to
nr_types. However, the current implementation uses an incorrect
traversal end type ID, so let's correct it.

Fixes: 19e00c897d50 ("libbpf: Split BTF relocation")
Signed-off-by: Pu Lehui &lt;pulehui@huawei.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20250115100241.4171581-3-pulehui@huaweicloud.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Fix return zero when elf_begin failed</title>
<updated>2025-02-08T09:01:39+00:00</updated>
<author>
<name>Pu Lehui</name>
<email>pulehui@huawei.com</email>
</author>
<published>2025-01-15T10:02:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b28e4c727597133a591a8ac2e53156de7fc31c0e'/>
<id>urn:sha1:b28e4c727597133a591a8ac2e53156de7fc31c0e</id>
<content type='text'>
[ Upstream commit 5436a54332c19df0acbef2b87cbf9f7cba56f2dd ]

The error number of elf_begin is omitted when encapsulating the
btf_find_elf_sections function.

Fixes: c86f180ffc99 ("libbpf: Make btf_parse_elf process .BTF.base transparently")
Signed-off-by: Pu Lehui &lt;pulehui@huawei.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20250115100241.4171581-2-pulehui@huaweicloud.com
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Fix segfault due to libelf functions not setting errno</title>
<updated>2025-02-08T09:01:31+00:00</updated>
<author>
<name>Quentin Monnet</name>
<email>qmo@kernel.org</email>
</author>
<published>2024-12-05T13:59:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4991c334a6e71eb3be97f6a4cf11a945d9e836da'/>
<id>urn:sha1:4991c334a6e71eb3be97f6a4cf11a945d9e836da</id>
<content type='text'>
[ Upstream commit e10500b69c3f3378f3dcfc8c2fe4cdb74fc844f5 ]

Libelf functions do not set errno on failure. Instead, it relies on its
internal _elf_errno value, that can be retrieved via elf_errno (or the
corresponding message via elf_errmsg()). From "man libelf":

    If a libelf function encounters an error it will set an internal
    error code that can be retrieved with elf_errno. Each thread
    maintains its own separate error code. The meaning of each error
    code can be determined with elf_errmsg, which returns a string
    describing the error.

As a consequence, libbpf should not return -errno when a function from
libelf fails, because an empty value will not be interpreted as an error
and won't prevent the program to stop. This is visible in
bpf_linker__add_file(), for example, where we call a succession of
functions that rely on libelf:

    err = err ?: linker_load_obj_file(linker, filename, opts, &amp;obj);
    err = err ?: linker_append_sec_data(linker, &amp;obj);
    err = err ?: linker_append_elf_syms(linker, &amp;obj);
    err = err ?: linker_append_elf_relos(linker, &amp;obj);
    err = err ?: linker_append_btf(linker, &amp;obj);
    err = err ?: linker_append_btf_ext(linker, &amp;obj);

If the object file that we try to process is not, in fact, a correct
object file, linker_load_obj_file() may fail with errno not being set,
and return 0. In this case we attempt to run linker_append_elf_sysms()
and may segfault.

This can happen (and was discovered) with bpftool:

    $ bpftool gen object output.o sample_ret0.bpf.c
    libbpf: failed to get ELF header for sample_ret0.bpf.c: invalid `Elf' handle
    zsh: segmentation fault (core dumped)  bpftool gen object output.o sample_ret0.bpf.c

Fix the issue by returning a non-null error code (-EINVAL) when libelf
functions fail.

Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs")
Signed-off-by: Quentin Monnet &lt;qmo@kernel.org&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20241205135942.65262-1-qmo@kernel.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: don't adjust USDT semaphore address if .stapsdt.base addr is missing</title>
<updated>2025-02-08T09:01:30+00:00</updated>
<author>
<name>Andrii Nakryiko</name>
<email>andrii@kernel.org</email>
</author>
<published>2024-11-21T22:45:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=25a7c6605fc80eac023a1082bd6a9668d3b690d4'/>
<id>urn:sha1:25a7c6605fc80eac023a1082bd6a9668d3b690d4</id>
<content type='text'>
[ Upstream commit 98ebe5ef6f5c4517ba92fb3e56f95827ebea83fd ]

USDT ELF note optionally can record an offset of .stapsdt.base, which is
used to make adjustments to USDT target attach address. Currently,
libbpf will do this address adjustment unconditionally if it finds
.stapsdt.base ELF section in target binary. But there is a corner case
where .stapsdt.base ELF section is present, but specific USDT note
doesn't reference it. In such case, libbpf will basically just add base
address and end up with absolutely incorrect USDT target address.

This adjustment has to be done only if both .stapsdt.sema section is
present and USDT note is recording a reference to it.

Fixes: 74cc6311cec9 ("libbpf: Add USDT notes parsing and resolution logic")
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Acked-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Link: https://lore.kernel.org/r/20241121224558.796110-1-andrii@kernel.org
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Change hash_combine parameters from long to unsigned long</title>
<updated>2024-11-16T19:01:38+00:00</updated>
<author>
<name>Sidong Yang</name>
<email>sidong.yang@furiosa.ai</email>
</author>
<published>2024-11-16T08:10:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2c8b09ac2537299511c898bc71b1a5f2756c831c'/>
<id>urn:sha1:2c8b09ac2537299511c898bc71b1a5f2756c831c</id>
<content type='text'>
The hash_combine() could be trapped when compiled with sanitizer like "zig cc"
or clang with signed-integer-overflow option. This patch parameters and return
type to unsigned long to remove the potential overflow.

Signed-off-by: Sidong Yang &lt;sidong.yang@furiosa.ai&gt;
Acked-by: Yonghong Song &lt;yonghong.song@linux.dev&gt;
Link: https://lore.kernel.org/r/20241116081054.65195-1-sidong.yang@furiosa.ai
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Fix memory leak in bpf_program__attach_uprobe_multi</title>
<updated>2024-11-15T19:29:12+00:00</updated>
<author>
<name>Jiri Olsa</name>
<email>jolsa@kernel.org</email>
</author>
<published>2024-11-15T11:58:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=fab974e6487475c2fca0a79918e8e75bd6bafffc'/>
<id>urn:sha1:fab974e6487475c2fca0a79918e8e75bd6bafffc</id>
<content type='text'>
Andrii reported memory leak detected by Coverity on error path
in bpf_program__attach_uprobe_multi. Fixing that by moving
the check earlier before the offsets allocations.

Reported-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Jiri Olsa &lt;jolsa@kernel.org&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20241115115843.694337-1-jolsa@kernel.org
</content>
</entry>
<entry>
<title>libbpf: Stringify errno in log messages in the remaining code</title>
<updated>2024-11-12T04:29:45+00:00</updated>
<author>
<name>Mykyta Yatsenko</name>
<email>yatsenko@meta.com</email>
</author>
<published>2024-11-11T21:29:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=4ce16ddd71054b1e47a65f8af5e3af6b64908e46'/>
<id>urn:sha1:4ce16ddd71054b1e47a65f8af5e3af6b64908e46</id>
<content type='text'>
Convert numeric error codes into the string representations in log
messages in the rest of libbpf source files.

Signed-off-by: Mykyta Yatsenko &lt;yatsenko@meta.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20241111212919.368971-5-mykyta.yatsenko5@gmail.com
</content>
</entry>
<entry>
<title>libbpf: Stringify errno in log messages in btf*.c</title>
<updated>2024-11-12T04:29:45+00:00</updated>
<author>
<name>Mykyta Yatsenko</name>
<email>yatsenko@meta.com</email>
</author>
<published>2024-11-11T21:29:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=af8380d51948e7e5566b5a659c78eb25e1b09f6c'/>
<id>urn:sha1:af8380d51948e7e5566b5a659c78eb25e1b09f6c</id>
<content type='text'>
Convert numeric error codes into the string representations in log
messages in btf.c and btf_dump.c.

Signed-off-by: Mykyta Yatsenko &lt;yatsenko@meta.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20241111212919.368971-4-mykyta.yatsenko5@gmail.com
</content>
</entry>
<entry>
<title>libbpf: Stringify errno in log messages in libbpf.c</title>
<updated>2024-11-12T04:29:45+00:00</updated>
<author>
<name>Mykyta Yatsenko</name>
<email>yatsenko@meta.com</email>
</author>
<published>2024-11-11T21:29:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=271abf041cb354ce99df33ce1f99db79faf90477'/>
<id>urn:sha1:271abf041cb354ce99df33ce1f99db79faf90477</id>
<content type='text'>
Convert numeric error codes into the string representations in log
messages in libbpf.c.

Signed-off-by: Mykyta Yatsenko &lt;yatsenko@meta.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20241111212919.368971-3-mykyta.yatsenko5@gmail.com
</content>
</entry>
<entry>
<title>libbpf: Introduce errstr() for stringifying errno</title>
<updated>2024-11-12T04:29:20+00:00</updated>
<author>
<name>Mykyta Yatsenko</name>
<email>yatsenko@meta.com</email>
</author>
<published>2024-11-11T21:29:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=1633a83bf993fa1eb8df26ec6043f77a2fe03245'/>
<id>urn:sha1:1633a83bf993fa1eb8df26ec6043f77a2fe03245</id>
<content type='text'>
Add function errstr(int err) that allows converting numeric error codes
into string representations.

Signed-off-by: Mykyta Yatsenko &lt;yatsenko@meta.com&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20241111212919.368971-2-mykyta.yatsenko5@gmail.com
</content>
</entry>
</feed>
