aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorStephen Smalley <[email protected]>2024-08-26 12:47:09 +0000
committerPaul Moore <[email protected]>2024-08-26 22:39:16 +0000
commit2571bb9d553ba2b8db1971bd3c903bff07d0bb11 (patch)
tree3f0462beb870009d0ca64d2c27ced0ec0dbbc71f /security/selinux/hooks.c
parentselinux: refactor code to return ERR_PTR in selinux_netlbl_sock_genattr (diff)
downloadkernel-2571bb9d553ba2b8db1971bd3c903bff07d0bb11.tar.gz
kernel-2571bb9d553ba2b8db1971bd3c903bff07d0bb11.zip
selinux: annotate false positive data race to avoid KCSAN warnings
KCSAN flags the check of isec->initialized by __inode_security_revalidate() as a data race. This is indeed a racy check, but inode_doinit_with_dentry() will recheck with isec->lock held. Annotate the check with the data_race() macro to silence the KCSAN false positive. Reported-by: [email protected] Signed-off-by: Stephen Smalley <[email protected]> Signed-off-by: Paul Moore <[email protected]>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 55c78c318ccd..70c335846336 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -282,8 +282,13 @@ static int __inode_security_revalidate(struct inode *inode,
might_sleep_if(may_sleep);
+ /*
+ * The check of isec->initialized below is racy but
+ * inode_doinit_with_dentry() will recheck with
+ * isec->lock held.
+ */
if (selinux_initialized() &&
- isec->initialized != LABEL_INITIALIZED) {
+ data_race(isec->initialized != LABEL_INITIALIZED)) {
if (!may_sleep)
return -ECHILD;