[PATCH] ovl: put the copy-up credentials when the copy_up hook fails
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Dec 3 10:41:07 UTC 2026
> The security_inode_copy_up() function calls the inode_copy_up hook of
> every LSM in turn and stops at the first error. SELinux and Smack
> allocate new credentials with prepare_creds() and return them in
> *new. If an LSM which runs after them fails the hook, for example a
> BPF LSM program which denies the copy-up, ovl_prepare_copy_up_creds()
> returns the error and the credentials leak. Nobody puts them: the
> cleanup of the copy_up_creds class skips error pointers.
>
> Put the credentials before returning the error. put_cred() accepts
> NULL, so this is also right when no LSM allocated them.
>
> Fixes: d8ad8b496184 ("security, overlayfs: provide copy up security hook for unioned files")
> Signed-off-by: Anton Protopopov <a.s.protopopov at gmail.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203104244.1015716-1-a.s.protopopov@gmail.com?part=1
More information about the Linux-security-module-archive
mailing list