[PATCH v5 5/8] lsm: Add memcg_charge_cgroup LSM hook
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Wed Nov 18 08:41:02 UTC 2026
> Similar to how security_memcg_charge_task adds an access-control
> point for pidfd for the charge_fd of a DMA_HEAP_IOCTL_ALLOC or
> DMA_BUF_IOCTL_XFER_CHARGE ioctl, we need a new access-control point
> for the case where charge_fd represents a cgroupfd.
>
> Add security_memcg_charge_cgroup(), called in get_obj_cgroup_from_fd()
> when charge_fd refers to a cgroup2. The hook receives the credentials
> of the requesting process (cred) and the open file of the cgroup
> directory to charge (file), giving security modules a controlled
> enforcement point for cross-cgroup memcg attribution policy.
>
> The file is passed instead of the cgroup so that a module can
> label-check the object the cgroupfd actually names.
> get_obj_cgroup_from_fd() resolves the memory css from that same file
> with css_tryget_online_from_dir(), so the fd cannot be swapped between
> the check and the charge.
>
> When CONFIG_SECURITY is not set the hook compiles to an inline
> returning 0, adding no overhead to the fast path.
>
> 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=5
More information about the Linux-security-module-archive
mailing list