From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
kernel-team@fb.com, yonghong.song@linux.dev, cnitlrt@gmail.com,
Eduard Zingerman <eddyz87@gmail.com>
Subject: [PATCH bpf-next v2 0/2] bpf: fix null pointer access for malformed BPF_CORE_TYPE_ID_LOCAL relos
Date: Wed, 21 Aug 2024 17:18:35 -0700 [thread overview]
Message-ID: <20240822001837.2715909-1-eddyz87@gmail.com> (raw)
Liu RuiTong reported an in-kernel null pointer derefence when
processing BPF_CORE_TYPE_ID_LOCAL relocations referencing non-existing
BTF types. Fix this by adding proper id checks.
Changes v1->v2:
- moved check from bpf_core_calc_relo_insn() to bpf_core_apply()
now both in kernel and in libbpf relocation type id is guaranteed
to exist when bpf_core_calc_relo_insn() is called;
- added a test case.
v1: https://lore.kernel.org/bpf/20240821164620.1056362-1-eddyz87@gmail.com/
Eduard Zingerman (2):
bpf: correctly handle malformed BPF_CORE_TYPE_ID_LOCAL relos
selftests/bpf: test for malformed BPF_CORE_TYPE_ID_LOCAL relocation
kernel/bpf/btf.c | 8 ++
.../selftests/bpf/prog_tests/core_reloc_raw.c | 124 ++++++++++++++++++
2 files changed, 132 insertions(+)
create mode 100644 tools/testing/selftests/bpf/prog_tests/core_reloc_raw.c
--
2.45.2
next reply other threads:[~2024-08-22 0:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-22 0:18 Eduard Zingerman [this message]
2024-08-22 0:18 ` [PATCH bpf-next v2 1/2] bpf: correctly handle malformed BPF_CORE_TYPE_ID_LOCAL relos Eduard Zingerman
2024-08-22 4:29 ` Andrii Nakryiko
2024-08-22 0:18 ` [PATCH bpf-next v2 2/2] selftests/bpf: test for malformed BPF_CORE_TYPE_ID_LOCAL relocation Eduard Zingerman
2024-08-22 4:29 ` Andrii Nakryiko
2024-08-22 4:39 ` Eduard Zingerman
2024-08-22 16:51 ` Andrii Nakryiko
2024-08-22 16:55 ` Alexei Starovoitov
2024-08-22 17:27 ` Andrii Nakryiko
2024-08-22 17:53 ` Alexei Starovoitov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240822001837.2715909-1-eddyz87@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cnitlrt@gmail.com \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox