From: Ignacio Encinas <ignacio@iencinas.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org,
linux-kernel@vger.kernel.org,
syzbot+419c4b42acc36c420ad3@syzkaller.appspotmail.com,
Ignacio Encinas <ignacio@iencinas.com>
Subject: [PATCH v2] mm: annotate data race in update_hiwater_rss
Date: Mon, 31 Mar 2025 21:57:05 +0200 [thread overview]
Message-ID: <20250331-mm-maxrss-data-race-v2-1-cf958e6205bf@iencinas.com> (raw)
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>
next reply other threads:[~2025-03-31 19:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 19:57 Ignacio Encinas [this message]
2025-03-31 20:08 ` Pedro Falcato
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250331-mm-maxrss-data-race-v2-1-cf958e6205bf@iencinas.com \
--to=ignacio@iencinas.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+419c4b42acc36c420ad3@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox