[RFC PATCH 1/2] selinux: annotate intentional data race in inode_doinit_with_dentry()

From: Christian Göttsche

Date: Mon Feb 02 2026 - 08:49:15 EST


From: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>

Like other `isec->initialized == LABEL_INITIALIZED` checks annotate the
check in inode_doinit_with_dentry() with data_race to please KCSAN.

The value is rechecked next with lock held.

Reported-by: syzbot+9ab96b38b76bec93939a@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=9ab96b38b76bec93939a
Signed-off-by: Christian Göttsche <cgzones@xxxxxxxxxxxxxx>
---
security/selinux/hooks.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index feda34b18d83..21064d45a910 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1436,7 +1436,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
struct dentry *dentry;
int rc = 0;

- if (isec->initialized == LABEL_INITIALIZED)
+ /* check below is racy, but we will recheck with lock held */
+ if (data_race(isec->initialized == LABEL_INITIALIZED))
return 0;

spin_lock(&isec->lock);
--
2.51.0