linux-stable/kernel/cgroup
Tejun Heo b8a2e3f93d cgroup: Make current_cgns_cgroup_dfl() safe to call after exit_task_namespace()
The commit 332ea1f697 ("bpf: Add bpf_cgroup_from_id() kfunc") added
bpf_cgroup_from_id() which calls current_cgns_cgroup_dfl() through
cgroup_get_from_id(). However, BPF programs may be attached to a point where
current->nsproxy has already been cleared to NULL by exit_task_namespace()
and calling bpf_cgroup_from_id() would cause an oops.

Just return the system-wide root if nsproxy has been cleared. This allows
all cgroups to be looked up after the task passed through
exit_task_namespace(), which semantically makes sense. Given that the only
way to get this behavior is through BPF programs, it seems safe but let's
see what others think.

Fixes: 332ea1f697 ("bpf: Add bpf_cgroup_from_id() kfunc")
Signed-off-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/ZBDuVWiFj2jiz3i8@slm.duckdns.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2023-03-14 16:56:20 -07:00
..
cgroup-internal.h memcg: fix possible use-after-free in memcg_write_event_control() 2022-12-09 18:41:17 -08:00
cgroup-v1.c cgroup: Use cgroup_attach_{lock,unlock}() from cgroup_attach_task_all() 2022-08-26 11:14:34 -10:00
cgroup.c cgroup: Make current_cgns_cgroup_dfl() safe to call after exit_task_namespace() 2023-03-14 16:56:20 -07:00
cpuset.c cgroup changes for v6.3-rc1 2023-02-21 10:36:29 -08:00
debug.c
freezer.c cgroup: cleanup comments 2022-03-13 19:19:27 -10:00
legacy_freezer.c freezer,sched: Rewrite core freezer logic 2022-09-07 21:53:50 +02:00
Makefile cgroup: Add misc cgroup controller 2021-04-04 13:34:46 -04:00
misc.c misc_cgroup: remove error log to avoid log flood 2021-09-20 07:35:38 -10:00
namespace.c memcg: enable accounting for new namesapces and struct nsproxy 2021-09-03 09:58:12 -07:00
pids.c cgroup: add pids.peak interface for pids controller 2022-09-04 09:26:51 -10:00
rdma.c cgroup: fix spelling mistakes 2021-05-24 12:45:26 -04:00
rstat.c bpf: Add __bpf_kfunc tag to all kfuncs 2023-02-02 00:25:14 +01:00