Skip to content

Commit

Permalink
selinux: annotate false positive data race to avoid KCSAN warnings
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
stephensmalley authored and pcmoore committed Aug 26, 2024
1 parent fc328c8 commit 2571bb9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion security/selinux/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2571bb9

Please sign in to comment.