Files
linux-stable-mirror/kernel
Qi Tang 10bc4a4dcd bpf: reject direct access to nullable PTR_TO_BUF pointers
[ Upstream commit b0db1accbc ]

check_mem_access() matches PTR_TO_BUF via base_type() which strips
PTR_MAYBE_NULL, allowing direct dereference without a null check.

Map iterator ctx->key and ctx->value are PTR_TO_BUF | PTR_MAYBE_NULL.
On stop callbacks these are NULL, causing a kernel NULL dereference.

Add a type_may_be_null() guard to the PTR_TO_BUF branch, matching the
existing PTR_TO_BTF_ID pattern.

Fixes: 20b2aff4bc ("bpf: Introduce MEM_RDONLY flag")
Signed-off-by: Qi Tang <tpluszz77@gmail.com>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20260402092923.38357-2-tpluszz77@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2026-04-18 10:33:31 +02:00
..
2025-12-07 06:09:29 +09:00
2025-06-27 11:05:38 +01:00
2026-04-18 10:33:11 +02:00
2024-10-17 15:12:00 +02:00
2024-10-17 15:11:27 +02:00