Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/shmem: annotate benign data-race in shmem_getattr()
@ 2026-07-08 11:19 Jaeyeon Lee
  0 siblings, 0 replies; only message in thread
From: Jaeyeon Lee @ 2026-07-08 11:19 UTC (permalink / raw)
  To: akpm, hughd
  Cc: baolin.wang, elver, linux-mm, linux-kernel, Jaeyeon Lee,
	syzbot+dfb578404df369f6599b

shmem_getattr() reads info->alloced, info->swapped and
i_mapping->nrpages without info->lock to decide whether
shmem_recalc_inode() should be called. shmem_recalc_inode()
recomputes these under info->lock, so a stale read here only
affects whether shmem_recalc_inode() runs.

Annotate data_race() to silence KCSAN.

Reported-by: syzbot+dfb578404df369f6599b@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=dfb578404df369f6599b
Signed-off-by: Jaeyeon Lee <jaeyeon.lee.dev@gmail.com>
---
 mm/shmem.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/shmem.c b/mm/shmem.c
index 0ea74fa84f25..3fb6dbbfa20b 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1287,7 +1287,8 @@ static int shmem_getattr(struct mnt_idmap *idmap,
 	struct inode *inode = path->dentry->d_inode;
 	struct shmem_inode_info *info = SHMEM_I(inode);
 
-	if (info->alloced - info->swapped != inode->i_mapping->nrpages)
+	/* Fast-path hint; recalc under info->lock corrects any stale read. */
+	if (data_race(info->alloced - info->swapped != inode->i_mapping->nrpages))
 		shmem_recalc_inode(inode, 0, 0);
 
 	if (info->fsflags & FS_APPEND_FL)
-- 
2.43.0



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-07-08 11:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08 11:19 [PATCH] mm/shmem: annotate benign data-race in shmem_getattr() Jaeyeon Lee

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox