<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/lib/bpf/btf.c, branch linux-5.10.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.10.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2023-03-11T15:39:17Z</updated>
<entry>
<title>libbpf: Fix btf__align_of() by taking into account field offsets</title>
<updated>2023-03-11T15:39:17Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2022-12-12T21:15:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3938f01405d61fde44b25a960c2d6cc851c80467'/>
<id>urn:sha1:3938f01405d61fde44b25a960c2d6cc851c80467</id>
<content type='text'>
[ Upstream commit 25a4481b4136af7794e1df2d6c90ed2f354d60ce ]

btf__align_of() is supposed to be return alignment requirement of
a requested BTF type. For STRUCT/UNION it doesn't always return correct
value, because it calculates alignment only based on field types. But
for packed structs this is not enough, we need to also check field
offsets and struct size. If field offset isn't aligned according to
field type's natural alignment, then struct must be packed. Similarly,
if struct size is not a multiple of struct's natural alignment, then
struct must be packed as well.

This patch fixes this issue precisely by additionally checking these
conditions.

Fixes: 3d208f4ca111 ("libbpf: Expose btf__align_of() API")
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20221212211505.558851-5-andrii@kernel.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Fix BTF header parsing checks</title>
<updated>2021-11-18T13:04:10Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2021-10-23T00:31:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=50fcaa7155214dbc57c985bb55edb1eb8e880fdb'/>
<id>urn:sha1:50fcaa7155214dbc57c985bb55edb1eb8e880fdb</id>
<content type='text'>
[ Upstream commit c825f5fee19caf301d9821cd79abaa734322de26 ]

Original code assumed fixed and correct BTF header length. That's not
always the case, though, so fix this bug with a proper additional check.
And use actual header length instead of sizeof(struct btf_header) in
sanity checks.

Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
Reported-by: Evgeny Vereshchagin &lt;evvers@ya.ru&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20211023003157.726961-2-andrii@kernel.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Fix overflow in BTF sanity checks</title>
<updated>2021-11-18T13:04:10Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2021-10-23T00:31:56Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=12872fd7e40b08c92c90da6f7c16a11a65b68aa2'/>
<id>urn:sha1:12872fd7e40b08c92c90da6f7c16a11a65b68aa2</id>
<content type='text'>
[ Upstream commit 5245dafe3d49efba4d3285cf27ee1cc1eeafafc6 ]

btf_header's str_off+str_len or type_off+type_len can overflow as they
are u32s. This will lead to bypassing the sanity checks during BTF
parsing, resulting in crashes afterwards. Fix by using 64-bit signed
integers for comparison.

Fixes: d8123624506c ("libbpf: Fix BTF data layout checks and allow empty BTF")
Reported-by: Evgeny Vereshchagin &lt;evvers@ya.ru&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20211023003157.726961-1-andrii@kernel.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Allow loading empty BTFs</title>
<updated>2021-11-18T13:04:10Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2021-01-10T07:03:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=255eb8f8affd23a37c8823c167da9f9e9ad416d0'/>
<id>urn:sha1:255eb8f8affd23a37c8823c167da9f9e9ad416d0</id>
<content type='text'>
[ Upstream commit b8d52264df85ec12f370c0a8b28d0ac59a05877a ]

Empty BTFs do come up (e.g., simple kernel modules with no new types and
strings, compared to the vmlinux BTF) and there is nothing technically wrong
with them. So remove unnecessary check preventing loading empty BTFs.

Fixes: d8123624506c ("libbpf: Fix BTF data layout checks and allow empty BTF")
Reported-by: Christopher William Snowhill &lt;chris@kode54.net&gt;
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Daniel Borkmann &lt;daniel@iogearbox.net&gt;
Link: https://lore.kernel.org/bpf/20210110070341.1380086-2-andrii@kernel.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Fix BTF data layout checks and allow empty BTF</title>
<updated>2021-11-18T13:04:10Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-11-05T04:33:57Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4d4d6aa2ef803044badb1529a1bfb45680f4071e'/>
<id>urn:sha1:4d4d6aa2ef803044badb1529a1bfb45680f4071e</id>
<content type='text'>
[ Upstream commit d8123624506cd62730c9cd9c7672c698e462703d ]

Make data section layout checks stricter, disallowing overlap of types and
strings data.

Additionally, allow BTFs with no type data. There is nothing inherently wrong
with having BTF with no types (put potentially with some strings). This could
be a situation with kernel module BTFs, if module doesn't introduce any new
type information.

Also fix invalid offset alignment check for btf-&gt;hdr-&gt;type_off.

Fixes: 8a138aed4a80 ("bpf: btf: Add BTF support to libbpf")
Signed-off-by: Andrii Nakryiko &lt;andrii@kernel.org&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20201105043402.2530976-8-andrii@kernel.org
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>libbpf: Make btf_dump work with modifiable BTF</title>
<updated>2020-09-30T19:30:22Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-09-29T23:28:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9c6c5c48d7e9c00c541e0f1a5cea3a96767e825c'/>
<id>urn:sha1:9c6c5c48d7e9c00c541e0f1a5cea3a96767e825c</id>
<content type='text'>
Ensure that btf_dump can accommodate new BTF types being appended to BTF
instance after struct btf_dump was created. This came up during attemp to
use btf_dump for raw type dumping in selftests, but given changes are not
excessive, it's good to not have any gotchas in API usage, so I decided to
support such use case in general.

Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200929232843.1249318-2-andriin@fb.com
</content>
</entry>
<entry>
<title>libbpf: Fix uninitialized variable in btf_parse_type_sec</title>
<updated>2020-09-30T00:05:31Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-09-29T22:06:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=33433913459a6bfbfa808c202d6f5490aa43d7a7'/>
<id>urn:sha1:33433913459a6bfbfa808c202d6f5490aa43d7a7</id>
<content type='text'>
Fix obvious unitialized variable use that wasn't reported by compiler. libbpf
Makefile changes to catch such errors are added separately.

Fixes: 3289959b97ca ("libbpf: Support BTF loading and raw data output in both endianness")
Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: Martin KaFai Lau &lt;kafai@fb.com&gt;
Link: https://lore.kernel.org/bpf/20200929220604.833631-1-andriin@fb.com
</content>
</entry>
<entry>
<title>libbpf: Support BTF loading and raw data output in both endianness</title>
<updated>2020-09-29T19:21:23Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-09-29T04:30:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=3289959b97cac205df006fc79c88f042bf2765ab'/>
<id>urn:sha1:3289959b97cac205df006fc79c88f042bf2765ab</id>
<content type='text'>
Teach BTF to recognized wrong endianness and transparently convert it
internally to host endianness. Original endianness of BTF will be preserved
and used during btf__get_raw_data() to convert resulting raw data to the same
endianness and a source raw_data. This means that little-endian host can parse
big-endian BTF with no issues, all the type data will be presented to the
client application in native endianness, but when it's time for emitting BTF
to persist it in a file (e.g., after BTF deduplication), original non-native
endianness will be preserved and stored.

It's possible to query original endianness of BTF data with new
btf__endianness() API. It's also possible to override desired output
endianness with btf__set_endianness(), so that if application needs to load,
say, big-endian BTF and store it as little-endian BTF, it's possible to
manually override this. If btf__set_endianness() was used to change
endianness, btf__endianness() will reflect overridden endianness.

Given there are no known use cases for supporting cross-endianness for
.BTF.ext, loading .BTF.ext in non-native endianness is not supported.

Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Link: https://lore.kernel.org/bpf/20200929043046.1324350-3-andriin@fb.com
</content>
</entry>
<entry>
<title>selftests/bpf: Test BTF writing APIs</title>
<updated>2020-09-29T02:17:13Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-09-29T02:05:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9141f75a3279bab4a7d761c6050d96777b646767'/>
<id>urn:sha1:9141f75a3279bab4a7d761c6050d96777b646767</id>
<content type='text'>
Add selftests for BTF writer APIs.

Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Link: https://lore.kernel.org/bpf/20200929020533.711288-4-andriin@fb.com
</content>
</entry>
<entry>
<title>libbpf: Add btf__str_by_offset() as a more generic variant of name_by_offset</title>
<updated>2020-09-29T02:17:13Z</updated>
<author>
<name>Andrii Nakryiko</name>
</author>
<published>2020-09-29T02:05:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f86ed050bcee3b7daa420eb31a8b6d079701caab'/>
<id>urn:sha1:f86ed050bcee3b7daa420eb31a8b6d079701caab</id>
<content type='text'>
BTF strings are used not just for names, they can be arbitrary strings used
for CO-RE relocations, line/func infos, etc. Thus "name_by_offset" terminology
is too specific and might be misleading. Instead, introduce
btf__str_by_offset() API which uses generic string terminology.

Signed-off-by: Andrii Nakryiko &lt;andriin@fb.com&gt;
Signed-off-by: Alexei Starovoitov &lt;ast@kernel.org&gt;
Acked-by: John Fastabend &lt;john.fastabend@gmail.com&gt;
Link: https://lore.kernel.org/bpf/20200929020533.711288-3-andriin@fb.com
</content>
</entry>
</feed>
