Skip to content

Commit 2571bb9

Browse files
stephensmalleypcmoore
authored andcommitted
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]>
1 parent fc328c8 commit 2571bb9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

security/selinux/hooks.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,13 @@ static int __inode_security_revalidate(struct inode *inode,
282282

283283
might_sleep_if(may_sleep);
284284

285+
/*
286+
* The check of isec->initialized below is racy but
287+
* inode_doinit_with_dentry() will recheck with
288+
* isec->lock held.
289+
*/
285290
if (selinux_initialized() &&
286-
isec->initialized != LABEL_INITIALIZED) {
291+
data_race(isec->initialized != LABEL_INITIALIZED)) {
287292
if (!may_sleep)
288293
return -ECHILD;
289294

0 commit comments

Comments
 (0)