All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/2] bpf: Fix setting retval to -EPERM for cgroup hooks not returning errno
@ 2026-06-10 20:17 Xu Kuohai
  2026-06-10 20:17 ` [PATCH bpf-next 1/2] " Xu Kuohai
  2026-06-10 20:17 ` [PATCH bpf-next 2/2] selftests/bpf: Add retval test for bool and errno LSM cgroup hooks Xu Kuohai
  0 siblings, 2 replies; 5+ messages in thread
From: Xu Kuohai @ 2026-06-10 20:17 UTC (permalink / raw)
  To: bpf, linux-kernel
  Cc: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Yonghong Song, Matt Bobrowski, KP Singh, Stanislav Fomichev,
	YiFei Zhu

This series fixes the issue reported by sashiko in [1]. The issue is that,
when a cgroup BPF program exits with 0, bpf_prog_run_array_cg() sets
the hook return value to -EPERM if it is not a valid errno. This is
correct for errno-based hooks, which return 0 on success and negative
errno on failure, but wrong for void and boolean LSM hooks. Boolean
LSM hooks should only return true or false, and void LSM hooks have
no return value at all.

Fix it by skipping setting -EPERM for hooks not returning errno.

[1] https://lore.kernel.org/bpf/20260605144232.95A141F00893@smtp.kernel.org/

Xu Kuohai (2):
  bpf: Fix setting retval to -EPERM for cgroup hooks not returning errno
  selftests/bpf: Add retval test for bool and errno LSM cgroup hooks

 include/linux/bpf_lsm.h                       |  6 ++
 kernel/bpf/bpf_lsm.c                          | 20 +++++
 kernel/bpf/cgroup.c                           | 47 ++++++++---
 .../selftests/bpf/prog_tests/lsm_cgroup.c     | 79 +++++++++++++++++++
 .../testing/selftests/bpf/progs/lsm_cgroup.c  | 30 +++++++
 5 files changed, 169 insertions(+), 13 deletions(-)

-- 
2.43.0


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

end of thread, other threads:[~2026-06-10 13:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10 20:17 [PATCH bpf-next 0/2] bpf: Fix setting retval to -EPERM for cgroup hooks not returning errno Xu Kuohai
2026-06-10 20:17 ` [PATCH bpf-next 1/2] " Xu Kuohai
2026-06-10 12:45   ` sashiko-bot
2026-06-10 13:26     ` Xu Kuohai
2026-06-10 20:17 ` [PATCH bpf-next 2/2] selftests/bpf: Add retval test for bool and errno LSM cgroup hooks Xu Kuohai

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.