All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf 0/2] bpf: Mark bpf_get_kmem_cache() as nullable
@ 2026-06-20 15:47 Nuoqi Gui
  2026-06-20 15:47 ` [PATCH bpf 1/2] " Nuoqi Gui
  2026-06-20 15:47 ` [PATCH bpf 2/2] selftests/bpf: Cover bpf_get_kmem_cache() null return Nuoqi Gui
  0 siblings, 2 replies; 4+ messages in thread
From: Nuoqi Gui @ 2026-06-20 15:47 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan,
	bpf, linux-kselftest, linux-kernel, Nuoqi Gui

bpf_get_kmem_cache() can return NULL when the supplied address is not a
valid kernel address or when no slab is found for it. Its kfunc
registration does not currently advertise that to the verifier.

Add KF_RET_NULL to the registration and add verifier coverage for the direct
field-read case. The selftest rejects a read of s->size after
bpf_get_kmem_cache(0) without a null check, while the null-checked variant
remains accepted.

The issue dates back to a992d7a397912 ("mm/bpf: Add bpf_get_kmem_cache()
kfunc").

Signed-off-by: Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>
---
Nuoqi Gui (2):
      bpf: Mark bpf_get_kmem_cache() as nullable
      selftests/bpf: Cover bpf_get_kmem_cache() null return

 kernel/bpf/helpers.c                               |  2 +-
 .../bpf/progs/verifier_kfunc_prog_types.c          | 29 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
---
base-commit: 76f62d237538b456354a44e796a541cde03c6e28
change-id: 20260617-f01-16-kmem-cache-ret-null-53a9f52fd835

Best regards,
--  
Nuoqi Gui <gnq25@mails.tsinghua.edu.cn>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-20 17:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-20 15:47 [PATCH bpf 0/2] bpf: Mark bpf_get_kmem_cache() as nullable Nuoqi Gui
2026-06-20 15:47 ` [PATCH bpf 1/2] " Nuoqi Gui
2026-06-20 17:47   ` Alexei Starovoitov
2026-06-20 15:47 ` [PATCH bpf 2/2] selftests/bpf: Cover bpf_get_kmem_cache() null return Nuoqi Gui

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.