[PATCH v5 7/8] selinux: Restrict memcg charging to a cgroupfd target

sashiko-bot at kernel.org sashiko-bot at kernel.org
Wed Nov 18 08:41:04 UTC 2026


> The security_memcg_charge_cgroup() hook allows security modules to
> control which processes may charge memcg memory to an arbitrary cgroup
> named by a cgroupfd passed in charge_fd. Without a policy
> implementation, the hook is a no-op, so a domain that has both
> dma-heap access and CAP_SYS_RESOURCE can charge any cgroup outside
> its own subtree, and SELinux cannot say which targets are acceptable.
> 
> Implement selinux_memcg_charge_cgroup() using avc_has_perm() with a
> new cgroup object class and a charge_to permission. This is the
> counterpart of the process2 charge_to permission used for the pidfd
> path.
> 
> The target SID is the SID of the inode of the cgroup directory the
> cgroupfd refers to, so access control follows the cgroup filesystem
> labeling. Policy authors can then grant cross-cgroup charging selectively,
> for example:
> 
>   allow allocator_app_t cgroup_t:cgroup charge_to;
> 
> Signed-off-by: Albert Esteve <aesteve at redhat.com>

Sashiko has reviewed this patch and found no issues.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-v2_20230123_tjmercier_google_com-v5-0-1ce975f2a9ad@redhat.com?part=7




More information about the Linux-security-module-archive mailing list