]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mm: silence data-race in update_hiwater_rss
authorLance Yang <lance.yang@linux.dev>
Fri, 26 Sep 2025 09:24:26 +0000 (17:24 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 28 Sep 2025 18:51:33 +0000 (11:51 -0700)
KCSAN reports a data race on mm_cluster.hiwater_rss, which can be accessed
concurrently from various paths like page migration and memory unmapping
without synchronization.

Since hiwater_rss is a statistical field for accounting purposes, this
data race is benign.  Annotate both the read and write accesses with
data_race() to make KCSAN happy.

Link: https://lkml.kernel.org/r/20250926092426.43312-1-lance.yang@linux.dev
Signed-off-by: Lance Yang <lance.yang@linux.dev>
Reported-by: syzbot+60192c8877d0bc92a92b@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-mm/68d6364e.050a0220.3390a8.000d.GAE@google.com
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jann Horn <jannh@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Marco Elver <elver@google.com>
Cc: Rik van Riel <riel@surriel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/mm.h

index fcb1e72eea408aaf1693d1702e869e2a71dede7e..06978b4dbeb8986818d5512050ee39154fc380ba 100644 (file)
@@ -2742,7 +2742,7 @@ static inline void update_hiwater_rss(struct mm_struct *mm)
        unsigned long _rss = get_mm_rss(mm);
 
        if (data_race(mm->hiwater_rss) < _rss)
-               (mm)->hiwater_rss = _rss;
+               data_race(mm->hiwater_rss = _rss);
 }
 
 static inline void update_hiwater_vm(struct mm_struct *mm)