[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241130001423.1114965-2-surenb@google.com>
Date: Fri, 29 Nov 2024 16:14:23 -0800
From: Suren Baghdasaryan <surenb@...gle.com>
To: akpm@...ux-foundation.org
Cc: kent.overstreet@...ux.dev, pasha.tatashin@...een.com, rppt@...nel.org,
yuzhao@...gle.com, souravpanda@...gle.com, 00107082@....com,
linux-mm@...ck.org, linux-kernel@...r.kernel.org, surenb@...gle.com
Subject: [PATCH 2/2] alloc_tag: fix set_codetag_empty() when !CONFIG_MEM_ALLOC_PROFILING_DEBUG
It was recently noticed that set_codetag_empty() might be used not only
to mark NULL alloctag references as empty to avoid warnings but also to
reset valid tags (in clear_page_tag_ref()). Since set_codetag_empty() is
defined as NOOP for CONFIG_MEM_ALLOC_PROFILING_DEBUG=n, such use of
set_codetag_empty() leads to subtle bugs.
Fix set_codetag_empty() for CONFIG_MEM_ALLOC_PROFILING_DEBUG=n to reset
the tag reference.
Fixes: a8fc28dad6d5 ("alloc_tag: introduce clear_page_tag_ref() helper function")
Reported-by: David Wang <00107082@....com>
Closes: https://lore.kernel.org/lkml/20241124074318.399027-1-00107082@163.com/
Signed-off-by: Suren Baghdasaryan <surenb@...gle.com>
---
Applies over mm-unstable
include/linux/alloc_tag.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/linux/alloc_tag.h b/include/linux/alloc_tag.h
index 7c0786bdf9af..f6a1b73f5663 100644
--- a/include/linux/alloc_tag.h
+++ b/include/linux/alloc_tag.h
@@ -63,7 +63,12 @@ static inline void set_codetag_empty(union codetag_ref *ref)
#else /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
static inline bool is_codetag_empty(union codetag_ref *ref) { return false; }
-static inline void set_codetag_empty(union codetag_ref *ref) {}
+
+static inline void set_codetag_empty(union codetag_ref *ref)
+{
+ if (ref)
+ ref->ct = NULL;
+}
#endif /* CONFIG_MEM_ALLOC_PROFILING_DEBUG */
--
2.47.0.338.g60cca15819-goog
Powered by blists - more mailing lists