Go to file
Tejun Heo 8a887060af cgroup: Use open-time cgroup namespace for process migration perm checks
commit e57457641613fef0d147ede8bd6a3047df588b95 upstream.

cgroup process migration permission checks are performed at write time as
whether a given operation is allowed or not is dependent on the content of
the write - the PID. This currently uses current's cgroup namespace which is
a potential security weakness as it may allow scenarios where a less
privileged process tricks a more privileged one into writing into a fd that
it created.

This patch makes cgroup remember the cgroup namespace at the time of open
and uses it for migration permission checks instad of current's. Note that
this only applies to cgroup2 as cgroup1 doesn't have namespace support.

This also fixes a use-after-free bug on cgroupns reported in

 https://lore.kernel.org/r/00000000000048c15c05d0083397@google.com

Note that backporting this fix also requires the preceding patch.

Reported-by: "Eric W. Biederman" <ebiederm@xmission.com>
Suggested-by: Linus Torvalds <torvalds@linuxfoundation.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Reported-by: syzbot+50f5cf33a284ce738b62@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/00000000000048c15c05d0083397@google.com
Fixes: 5136f6365c ("cgroup: implement "nsdelegate" mount option")
Signed-off-by: Tejun Heo <tj@kernel.org>
[mkoutny: v5.10: duplicate ns check in procs/threads write handler, adjust context]
Signed-off-by: Michal Koutný <mkoutny@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[OP: backport to v5.4: drop changes to cgroup_attach_permissions() and
cgroup_css_set_fork(), adjust cgroup_procs_write_permission() calls]
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-15 14:18:41 +02:00
arch arm64: module: remove (NOLOAD) from linker script 2022-04-15 14:18:40 +02:00
block Revert "Revert "block, bfq: honor already-setup queue merges"" 2022-04-15 14:18:23 +02:00
certs
crypto
Documentation dt-bindings: spi: mxic: The interrupt property is not mandatory 2022-04-15 14:18:30 +02:00
drivers drm/amdkfd: Fix -Wstrict-prototypes from amdgpu_amdkfd_gfx_10_0_get_functions() 2022-04-15 14:18:41 +02:00
fs io_uring: fix fs->users overflow 2022-04-15 14:18:41 +02:00
include mm/sparsemem: fix 'mem_section' will never be NULL gcc 12 warning 2022-04-15 14:18:40 +02:00
init init/main.c: return 1 from handled __setup() functions 2022-04-15 14:18:35 +02:00
ipc
kernel cgroup: Use open-time cgroup namespace for process migration perm checks 2022-04-15 14:18:41 +02:00
lib lz4: fix LZ4_decompress_safe_partial read out of bound 2022-04-15 14:18:39 +02:00
LICENSES
mm mm: don't skip swap entry even if zap_details specified 2022-04-15 14:18:40 +02:00
net SUNRPC: Handle low memory situations in call_status() 2022-04-15 14:18:38 +02:00
samples
scripts
security Fix incorrect type in assignment of ipv6 port for audit 2022-04-15 14:18:22 +02:00
sound ASoC: topology: Allow TLV control to be either read or write 2022-04-15 14:18:30 +02:00
tools tools build: Use $(shell ) instead of `` to get embedded libperl's ccopts 2022-04-15 14:18:40 +02:00
usr
virt KVM: Prevent module exit until all VMs are freed 2022-04-15 14:18:27 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.