* [PATCH v2] mm: annotate data race in update_hiwater_rss
@ 2025-03-31 19:57 Ignacio Encinas
2025-03-31 20:08 ` Pedro Falcato
0 siblings, 1 reply; 2+ messages in thread
From: Ignacio Encinas @ 2025-03-31 19:57 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-mm, Lorenzo Stoakes, Liam R. Howlett, linux-kernel-mentees,
skhan, linux-kernel, syzbot+419c4b42acc36c420ad3,
Ignacio Encinas
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
---
| 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
--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>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] mm: annotate data race in update_hiwater_rss
2025-03-31 19:57 [PATCH v2] mm: annotate data race in update_hiwater_rss Ignacio Encinas
@ 2025-03-31 20:08 ` Pedro Falcato
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Falcato @ 2025-03-31 20:08 UTC (permalink / raw)
To: Ignacio Encinas
Cc: Andrew Morton, linux-mm, Lorenzo Stoakes, Liam R. Howlett,
linux-kernel-mentees, skhan, linux-kernel,
syzbot+419c4b42acc36c420ad3
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-03-31 20:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-31 19:57 [PATCH v2] mm: annotate data race in update_hiwater_rss Ignacio Encinas
2025-03-31 20:08 ` Pedro Falcato
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox