Skip to content

Commit 6ab42fe

Browse files
surenbaghdasaryanakpm00
authored andcommitted
alloc_tag: fix page_ext_get/page_ext_put sequence during page splitting
pgalloc_tag_sub() might call page_ext_put() using a page different from the one used in page_ext_get() call. This does not pose an issue since page_ext_put() ignores this parameter as long as it's non-NULL but technically this is wrong. Fix it by storing the original page used in page_ext_get() and passing it to page_ext_put(). Link: https://lkml.kernel.org/r/20240711220457.1751071-3-surenb@google.com Fixes: be25d1d ("mm: create new codetag references during page splitting") Signed-off-by: Suren Baghdasaryan <surenb@google.com> Cc: Kees Cook <keescook@chromium.org> Cc: Kent Overstreet <kent.overstreet@linux.dev> Cc: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Sourav Panda <souravpanda@google.com> Cc: Vlastimil Babka <vbabka@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent fd8acc0 commit 6ab42fe

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

include/linux/pgalloc_tag.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,15 @@ static inline void pgalloc_tag_sub(struct page *page, unsigned int nr)
7171
static inline void pgalloc_tag_split(struct page *page, unsigned int nr)
7272
{
7373
int i;
74+
struct page_ext *first_page_ext;
7475
struct page_ext *page_ext;
7576
union codetag_ref *ref;
7677
struct alloc_tag *tag;
7778

7879
if (!mem_alloc_profiling_enabled())
7980
return;
8081

81-
page_ext = page_ext_get(page);
82+
first_page_ext = page_ext = page_ext_get(page);
8283
if (unlikely(!page_ext))
8384
return;
8485

@@ -94,7 +95,7 @@ static inline void pgalloc_tag_split(struct page *page, unsigned int nr)
9495
page_ext = page_ext_next(page_ext);
9596
}
9697
out:
97-
page_ext_put(page_ext);
98+
page_ext_put(first_page_ext);
9899
}
99100

100101
static inline struct alloc_tag *pgalloc_tag_get(struct page *page)

0 commit comments

Comments
 (0)