From patchwork Mon Mar 31 19:57:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ignacio Encinas X-Patchwork-Id: 14033886 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DFA7C3600B for ; Mon, 31 Mar 2025 19:57:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 713CB280002; Mon, 31 Mar 2025 15:57:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6C254280001; Mon, 31 Mar 2025 15:57:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B12A280002; Mon, 31 Mar 2025 15:57:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 41A8E280001 for ; Mon, 31 Mar 2025 15:57:18 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D611580225 for ; Mon, 31 Mar 2025 19:57:18 +0000 (UTC) X-FDA: 83282905356.22.9B64119 Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) by imf30.hostedemail.com (Postfix) with ESMTP id D91EA8000A for ; Mon, 31 Mar 2025 19:57:16 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=iencinas.com header.s=key1 header.b=KzPGOxnq; spf=pass (imf30.hostedemail.com: domain of ignacio@iencinas.com designates 95.215.58.171 as permitted sender) smtp.mailfrom=ignacio@iencinas.com; dmarc=pass (policy=quarantine) header.from=iencinas.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1743451037; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=TR+EVp0RJxzPaDlgwVLkfyb7+8Z1TDtRU9YgZVmXlP4=; b=OJIyYcbOi23/7FLWxCFilY2SjXCOXXjkKnmsUAYtzMChVDWarMCCOlt1jR2PRhJfCrlHfS AJ4m4LloQ+NlRVaAv3FdYpAn1I19Ij6Vx69W5D38bRDXt7XeHqCWCNqWqvLw38qfMzFDZX 1XZqp+Ih22iVroroFGeqsR766H63QqI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=iencinas.com header.s=key1 header.b=KzPGOxnq; spf=pass (imf30.hostedemail.com: domain of ignacio@iencinas.com designates 95.215.58.171 as permitted sender) smtp.mailfrom=ignacio@iencinas.com; dmarc=pass (policy=quarantine) header.from=iencinas.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1743451037; a=rsa-sha256; cv=none; b=HGZmcgvZxfvPaWZztTRJiAt6YJcXuk4d6ISe3M9MQWrvNmkgiiWOXoiA38zTGRnc5vCcvs 7Dzv026c+bhDL4LEjdDzZ5WeNL3iYa8BbxQFp2mWkZcoAj4h6++e/E5HVG/etzgUu4j7uo 8IA3dmkVq9oQb3Pp9VrfEAfSZ+e42Og= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iencinas.com; s=key1; t=1743451034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=TR+EVp0RJxzPaDlgwVLkfyb7+8Z1TDtRU9YgZVmXlP4=; b=KzPGOxnqi02m1/QGqoIy6lUSOWqh/zNsGRSyD+7ednPnI8tXSADVVo8iYM+wuXt5VmRO1F +kMjlJ1eejMWaN1pDH3QChzJ9nxQedhBxKQsDFUsDP0yrgtcdw10J5WCdqsyKcvlbfbc7P Uwcsq0JEeg4Z0sn5X938v0Y0bJUJwI5sBlEBRnVb9CaqrjFAERdpOpQIaqnLt1POiC4FeG afhhz45VRVbSUr5ipuITpC/xniEh2zFMcAYKAS1HgMXpO4fLgUNub3WiRMPGBU8TLn7mNH fC83PVKte6RLNmQ57a1UA9Nc4t5FtpeRKqZ/2zVc2+BMtCsHhjulb3/9c/ezzQ== From: Ignacio Encinas Date: Mon, 31 Mar 2025 21:57:05 +0200 Subject: [PATCH v2] mm: annotate data race in update_hiwater_rss MIME-Version: 1.0 Message-Id: <20250331-mm-maxrss-data-race-v2-1-cf958e6205bf@iencinas.com> X-B4-Tracking: v=1; b=H4sIAJDz6mcC/22NywqDMBBFf0Vm3SlJfCBd9T+Ki0kc6ywSSyLBI v57U+myy3PgnrtD4iic4FbtEDlLkiUUMJcK3EzhyShjYTDKtKrWLXqPnraYEo60EkZyjJ3jvrN qZKsbKMtX5Em2s/oYCs+S1iW+z5Osv/bXq9XfXtao0UysLHW2b3pzFw5OAqWrWzwMx3F8AB0ws d65AAAA X-Change-ID: 20250315-mm-maxrss-data-race-6ce86b0deb14 To: Andrew Morton Cc: linux-mm@kvack.org, Lorenzo Stoakes , "Liam R. Howlett" , linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org, linux-kernel@vger.kernel.org, syzbot+419c4b42acc36c420ad3@syzkaller.appspotmail.com, Ignacio Encinas X-Migadu-Flow: FLOW_OUT X-Rspamd-Queue-Id: D91EA8000A X-Stat-Signature: zxaewpxbe4oja965u7yn3ffxd9gp5rsr X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1743451036-397436 X-HE-Meta: U2FsdGVkX19JFQCufL1EqobyYVB5RMbyLxeqoto/U2xaBJpktLiSVexjB1uy6o2lk0qMYcycZoblrvSmt+g8w7A6WFHu9n+uIn8vSgA+wd1LugDFd6dsoDkOFqKHiLF3nPC/UU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K4dHhKwlV4HLyg6PBhkONwqLFd8MLFiPiIjcujmFvoHUbz6s5gLyhUFq9vrH4LV6ooQ0ZN+dBeLlqJqjEBbQKaBFJdHU7bjkuDyK52MAEXJMEYAwgPUDooyHNJ2ksf/1L1RLg0VoUooIIS5bhMgCTpjNDYqMQG1zW0ASTw49mnhYDyQvIsWTFvnli2ESeAGvB3a61N9oV37uBZFx06/uRegscNb1skmEwvCl1diZcPfM9DD07NVbDYjRvbdRqwxjkBcifBtHXdMLCjG4jHUOfbIHbqEDfuwHm4zGmAj2rRNdmYzc7OQfwq/nXn+Ewe X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Ignacio Encinas Acked-by: Pedro Falcato --- 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(-) --- base-commit: 3571e8b091f4270d869dda7a6cc43616c6ad6897 change-id: 20250315-mm-maxrss-data-race-6ce86b0deb14 Best regards, 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 #include #include +#include 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; }