]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling
authorPaul Moore <paul@paul-moore.com>
Tue, 3 Nov 2020 16:49:38 +0000 (11:49 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 20 Jan 2021 13:25:38 +0000 (14:25 +0100)
commitea92a56f070823b9f53af5672f826936bd11b07c
tree8163c80cbbf9d395d30c78e2d30babc98287d3cb
parent7c2fb5c779bca9402eda237ac65fe33cb10cd8db
selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling

BugLink: https://bugs.launchpad.net/bugs/1910822
[ Upstream commit 200ea5a2292dc444a818b096ae6a32ba3caa51b9 ]

A previous fix, commit 83370b31a915 ("selinux: fix error initialization
in inode_doinit_with_dentry()"), changed how failures were handled
before a SELinux policy was loaded.  Unfortunately that patch was
potentially problematic for two reasons: it set the isec->initialized
state without holding a lock, and it didn't set the inode's SELinux
label to the "default" for the particular filesystem.  The later can
be a problem if/when a later attempt to revalidate the inode fails
and SELinux reverts to the existing inode label.

This patch should restore the default inode labeling that existed
before the original fix, without affecting the LABEL_INVALID marking
such that revalidation will still be attempted in the future.

Fixes: 83370b31a915 ("selinux: fix error initialization in inode_doinit_with_dentry()")
Reported-by: Sven Schnelle <svens@linux.ibm.com>
Tested-by: Sven Schnelle <svens@linux.ibm.com>
Reviewed-by: Ondrej Mosnacek <omosnace@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
security/selinux/hooks.c