include/linux/mm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm_struct.hiwater_rss can be accessed concurrently without proper
synchronization as reported by KCSAN.
This data race is benign as it only affects accounting information.
Annotate it with data_race() to make KCSAN happy.
Reported-by: syzbot+419c4b42acc36c420ad3@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/all/67e3390c.050a0220.1ec46.0001.GAE@google.com/
Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Ignacio Encinas <ignacio@iencinas.com>
---
Changes in v2:
- Annotate the actual race with data_race() instead of marking the
struct field as __data_racy as suggested by Lorenzo. The commit title
and description has been updated accordingly
I also changed (mm) to mm as the parenthesis are no longer necessary
(this particular snippet of code comes from an old macro)
- Add missing Closes tag for the syzbot report
- Link to v1: https://lore.kernel.org/r/20250330-mm-maxrss-data-race-v1-1-2fe0ba6b8482@iencinas.com
---
include/linux/mm.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 7b1068ddcbb70b732a4f2843e6b55fd73cc3e320..572b2001588b8afe68a468840cc75cd63cd4b543 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -32,6 +32,7 @@
#include <linux/memremap.h>
#include <linux/slab.h>
#include <linux/cacheinfo.h>
+#include <linux/compiler.h>
struct mempolicy;
struct anon_vma;
@@ -2665,7 +2666,7 @@ static inline void update_hiwater_rss(struct mm_struct *mm)
{
unsigned long _rss = get_mm_rss(mm);
- if ((mm)->hiwater_rss < _rss)
+ if (data_race(mm->hiwater_rss) < _rss)
(mm)->hiwater_rss = _rss;
}
---
base-commit: 3571e8b091f4270d869dda7a6cc43616c6ad6897
change-id: 20250315-mm-maxrss-data-race-6ce86b0deb14
Best regards,
--
Ignacio Encinas <ignacio@iencinas.com>
On Mon, Mar 31, 2025 at 09:57:05PM +0200, Ignacio Encinas wrote: > mm_struct.hiwater_rss can be accessed concurrently without proper > synchronization as reported by KCSAN. > > This data race is benign as it only affects accounting information. > Annotate it with data_race() to make KCSAN happy. > > Reported-by: syzbot+419c4b42acc36c420ad3@syzkaller.appspotmail.com > Closes: https://lore.kernel.org/all/67e3390c.050a0220.1ec46.0001.GAE@google.com/ > Suggested-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> > Signed-off-by: Ignacio Encinas <ignacio@iencinas.com> Looks good, thank you for the contribution! Acked-by: Pedro Falcato <pfalcato@suse.de> -- Pedro
© 2016 - 2025 Red Hat, Inc.