From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D58A01C5F27; Sun, 7 Jun 2026 10:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828079; cv=none; b=YH0BXsPF99HxTHVuJvFVljdW41mVkjXZAPwpTB+ovz/y9fugP4SSj6/DkNExIcAlA1AdYS8Dsi2jgpf1cy85UA9iT7YT1A9H2KZLoZCe1ckwa53xfZiQkK+Q4bY8nghWD0FUAelsDGWT9QqNGnGlGxmwJ2JXNT3rCdnKCqdgrHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780828079; c=relaxed/simple; bh=2t69vI1x6Cvw5WT8n/VkrC3ZWWfe+/beLl1XW+ekufg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dRQhqA3k2iua5XPw1+ZuZ3lucb3A2AT45n3cubz5UqbVYTadWQ7I4GpyqQXm8JLdYxtk+CDieysPKhuTLYg4WsORD/X/1qvrQ+ZVmLHpdA8Nrv4bp5sEb7MFJ6exs6kB3mBDDkdrT9/STjMz5NKjGopz3HbUeTIieja4FZgFfX4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=fvPJppBX; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="fvPJppBX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D70C31F00893; Sun, 7 Jun 2026 10:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780828078; bh=gJfeqlGF4ToxOxMDWyGzFapIWy6wINiq0V1jy082j8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fvPJppBXFBya4aZ5YMrLHpBDmN+x0RmH66IMi9HSYAdGtQPK5iIFwH9kq/ei2vGDe mXw2JhgkHtVNo8V9LllchstAxF+KIZTvn/Q1FdLpcVUyFmnRHOR27FGIH7nmOzO/C/ b8KaSWfKV3ZzqPP/bgJm4CmD1GPQZrgYmH/TVJlk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mikhail Gavrilov , Zi Yan , "David Hildenbrand (Arm)" , Vlastimil Babka , Brendan Jackman , Chris Li , Hugh Dickins , Johannes Weiner , Kairui Song , "Matthew Wilcox (Oracle)" , Michal Hocko , Nicholas Piggin , Suren Baghdasaryan , Andrew Morton , Li Wang , Sasha Levin Subject: [PATCH 6.12 109/307] mm/page_alloc: clear page->private in free_pages_prepare() Date: Sun, 7 Jun 2026 11:58:26 +0200 Message-ID: <20260607095731.781873154@linuxfoundation.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260607095727.647295505@linuxfoundation.org> References: <20260607095727.647295505@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mikhail Gavrilov [ Upstream commit ac1ea219590c09572ed5992dc233bbf7bb70fef9 ] Several subsystems (slub, shmem, ttm, etc.) use page->private but don't clear it before freeing pages. When these pages are later allocated as high-order pages and split via split_page(), tail pages retain stale page->private values. This causes a use-after-free in the swap subsystem. The swap code uses page->private to track swap count continuations, assuming freshly allocated pages have page->private == 0. When stale values are present, swap_count_continued() incorrectly assumes the continuation list is valid and iterates over uninitialized page->lru containing LIST_POISON values, causing a crash: KASAN: maybe wild-memory-access in range [0xdead000000000100-0xdead000000000107] RIP: 0010:__do_sys_swapoff+0x1151/0x1860 Fix this by clearing page->private in free_pages_prepare(), ensuring all freed pages have clean state regardless of previous use. Link: https://lkml.kernel.org/r/20260207173615.146159-1-mikhail.v.gavrilov@gmail.com Fixes: 3b8000ae185c ("mm/vmalloc: huge vmalloc backing pages should be split rather than compound") Signed-off-by: Mikhail Gavrilov Suggested-by: Zi Yan Acked-by: Zi Yan Acked-by: David Hildenbrand (Arm) Reviewed-by: Vlastimil Babka Cc: Brendan Jackman Cc: Chris Li Cc: Hugh Dickins Cc: Johannes Weiner Cc: Kairui Song Cc: Matthew Wilcox (Oracle) Cc: Michal Hocko Cc: Nicholas Piggin Cc: Suren Baghdasaryan Cc: Signed-off-by: Andrew Morton [backport: context only] Signed-off-by: Li Wang Signed-off-by: Sasha Levin --- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b1a8abe5005e99..259249a37faf01 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1158,6 +1158,7 @@ __always_inline bool free_pages_prepare(struct page *page, page_cpupid_reset_last(page); page->flags &= ~PAGE_FLAGS_CHECK_AT_PREP; + page->private = 0; reset_page_owner(page, order); page_table_check_free(page, order); pgalloc_tag_sub(page, 1 << order); -- 2.53.0