Bug 1194249 - (CVE-2021-45941) VUL-0: CVE-2021-45941: libbpf: heap-based buffer overflow (8 bytes) in __bpf_object__open (called from bpf_object__open_mem and bpf-object-fuzzer.c).
VUL-0: CVE-2021-45941: libbpf: heap-based buffer overflow (8 bytes) in __bpf_...
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents
Other Other
: P3 - Medium : Normal
: ---
Assigned To: Security Team bot
Security Team bot
Depends on:
  Show dependency treegraph
Reported: 2022-01-03 15:36 UTC by Alexander Bergmann
Modified: 2023-01-11 12:06 UTC (History)
7 users (show)

See Also:
Found By: Security Response Team
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Bergmann 2022-01-03 15:36:01 UTC

libbpf 0.6.0 and 0.6.1 has a heap-based buffer overflow (8 bytes) in
__bpf_object__open (called from bpf_object__open_mem and bpf-object-fuzzer.c).

Comment 1 Petr Gajdos 2022-01-04 10:04:37 UTC
This is interesting:

libbpf[1]> grep SUSE:SLE
SUSE:SLE-15-SP3:GA                                                 libbpf
SUSE:SLE-15-SP4:GA                                                 libbpf
libbpf[1]> isc ls SUSE:SLE-15-SP3:GA/libbpf
libbpf[0]> isc ls SUSE:SLE-15-SP4:GA/libbpf

How could that happen that there is just .spec and .changes?
Comment 2 Petr Gajdos 2022-01-04 10:20:04 UTC
(In reply to Petr Gajdos from comment #1)
> This is interesting:

Not really. BuildRequires:  kernel-source is the difference.
Comment 9 Shung-Hsi Yu 2022-09-30 04:47:50 UTC
This end up being an issue with how libbpf interpret the number of section header in an ELF file.

Usually the number of section header is store in the e_shnum field so the ELF header. However, when the number of section header is >= 65280/0xff00, e_shnum will be zero, with the actual number of section header stored in the sh_size field of the 0th section header.

I've confirm that using the elf_getshdrnum() helper to retrieve the number of section header instead of using e_shnum field directly fixes this issue CVE-2021-45941 and CVE-2021-45940 (bug 1194248).

I will submit this fix along with fixes for a few other fuzzer-reported bugs that I discovered while running the fuzzer locally soon.
Comment 11 Shung-Hsi Yu 2022-10-11 14:59:28 UTC
Fix proposed upstream <https://lore.kernel.org/bpf/20221007174816.17536-2-shung-hsi.yu@suse.com/>. But it still needs a few more changes before getting merged. Will provide an update once it happens.
Comment 12 Shung-Hsi Yu 2022-10-21 08:27:44 UTC
Fix is now merged upstream https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?h=for-next&id=51deedc9b8680953437dfe359e5268120de10e30, the same fix needed for bug 1194249.

This only affects Tumbleweed/Factory. I'll apply the fix there.
Comment 13 Shung-Hsi Yu 2022-10-21 08:49:54 UTC
(In reply to Shung-Hsi Yu from comment #12)
> Fix is now merged upstream
> https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/
> ?h=for-next&id=51deedc9b8680953437dfe359e5268120de10e30, the same fix needed
> for bug 1194249.

Should say bug 1194248.
Comment 14 Shung-Hsi Yu 2022-11-08 08:08:42 UTC
Fix submitted to Tumbleweed/Factory in SR#1034423.
Reassigning back to security team.