From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 224BD495533; Sat, 28 Feb 2026 17:46:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300766; cv=none; b=cwqqrCBhreDXLraZzNImyQ2Kss4G1SmifgroCW/UfRJBLkN1lBJDO7Y7TKji9xNYExUyhbK2YDPisD+tW3dlUPXwTP7vu6kFc/m5o4FAAXiXmgutCpuELk+idXZBmwvMRwjHaW9MQANCfVwaY2b1mGuA67+EyIl+rbt7IxjuqOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772300766; c=relaxed/simple; bh=5BRXygWSe9z9u0wEphqVihDWuv/lI+QkbvdRomdKYdQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cfulKybNwO3IOeqVqBpqqI+6EsqXjY2G9LnVIfm7KDqQTgO9CMeVtAR3zoOY3aLM+zLGxXSE4+wQxCHpBnTqniRFe+xRB1y3NnY/Iv73Oz9pVq1AC1nthCEuuspqF3tmuXv4IQBHWlCCyBHRKbxw+PMLYsNxsO3u7glxlZU3ebs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mOlPCHFH; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mOlPCHFH" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C7D0C19424; Sat, 28 Feb 2026 17:46:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1772300766; bh=5BRXygWSe9z9u0wEphqVihDWuv/lI+QkbvdRomdKYdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mOlPCHFHd0CY1xwZArIjbHmOFruZWG9DqiFrPkVbUcgSl9/JCB9ZUshdJKeLUSBxx 61z4nUV/0DduT7QVBKyTXUsBL0jqC/+6+QJBV63fU3/xAJr/Ju97CWUhmUsTccK3iR O7GIzwqhDAgrVmMS0yNBTE5Cpm6V4qLEd6aFGC83+X3KXoapshLbXJF+2ePE5QkSRH 0ToFV4Egz76DGYE8ij9J3O9iuqBnetlDrmyABlMGLC4BrhTXgpg6blcHlhnsojGr0i 6aNeLt3+0Z0+D8fcDgLj3ne7uaK3tF3BIhEZVswaKBGha7BqcezQ30sijZbAsk7ExS x5ZPpO+rIQNow== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: 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 , Sasha Levin Subject: [PATCH 6.19 797/844] mm/page_alloc: clear page->private in free_pages_prepare() Date: Sat, 28 Feb 2026 12:31:50 -0500 Message-ID: <20260228173244.1509663-798-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260228173244.1509663-1-sashal@kernel.org> References: <20260228173244.1509663-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit 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 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 48af3d7b47849..04e32adaeb1dd 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1430,6 +1430,7 @@ __always_inline bool __free_pages_prepare(struct page *page, page_cpupid_reset_last(page); page->flags.f &= ~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.51.0