OSDN Git Service

selinux: fall back to ref-walk if audit is required
authorStephen Smalley <sds@tycho.nsa.gov>
Fri, 22 Nov 2019 17:22:45 +0000 (12:22 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Feb 2020 07:34:40 +0000 (08:34 +0100)
commitefd5ce8b23a838f6577ecb8f28cd36568b4f49df
treebdfd12ff18036ec1268cd2d16ba1eae93069bb9b
parentec0237cb3621974af9ffe5aef452d1dbc4103ef8
selinux: fall back to ref-walk if audit is required

[ Upstream commit 0188d5c025ca8fe756ba3193bd7d150139af5a88 ]

commit bda0be7ad994 ("security: make inode_follow_link RCU-walk aware")
passed down the rcu flag to the SELinux AVC, but failed to adjust the
test in slow_avc_audit() to also return -ECHILD on LSM_AUDIT_DATA_DENTRY.
Previously, we only returned -ECHILD if generating an audit record with
LSM_AUDIT_DATA_INODE since this was only relevant from inode_permission.
Move the handling of MAY_NOT_BLOCK to avc_audit() and its inlined
equivalent in selinux_inode_permission() immediately after we determine
that audit is required, and always fall back to ref-walk in this case.

Fixes: bda0be7ad994 ("security: make inode_follow_link RCU-walk aware")
Reported-by: Will Deacon <will@kernel.org>
Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
security/selinux/avc.c
security/selinux/hooks.c
security/selinux/include/avc.h