FAILED: patch "[PATCH] debugfs: fix security_locked_down() call for SELinux" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 5881fa8dc2de9697a89451f6518e8b3a796c09c6 Mon Sep 17 00:00:00 2001
From: Ondrej Mosnacek <[email protected]>
Date: Fri, 7 May 2021 14:53:04 +0200
Subject: [PATCH] debugfs: fix security_locked_down() call for SELinux
When (ia->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) is zero, then the SELinux implementation of the locked_down hook might report a denial even though the operation would actually be allowed.
To fix this, make sure that security_locked_down() is called only when the return value will be taken into account (i.e. when changing one of the problematic attributes).
Note: this was introduced by commit 5496197f9b08 ("debugfs: Restrict debugfs when the kernel is locked down"), but it didn't matter at that time, as the SELinux support came in later.
fs/debugfs/inode.c +6 -3
@@ -45,10 +45,13 @@ static unsigned int debugfs_allow __ro_after_init = DEFAULT_DEBUGFS_ALLOW_BITS;static int debugfs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry,struct iattr *ia) { -int ret =security_locked_down (LOCKDOWN_DEBUGFS ); +int ret; -if (ret && (ia->ia_valid & (ATTR_MODE |ATTR_UID |ATTR_GID ))) -return ret; +if (ia->ia_valid & (ATTR_MODE |ATTR_UID |ATTR_GID )) { + ret =security_locked_down (LOCKDOWN_DEBUGFS ); +if (ret) +return ret; + }return simple_setattr (&init_user_ns, dentry, ia); }