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 5913F3563FF for ; Wed, 21 Jan 2026 03:14:32 +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=1768965272; cv=none; b=bffAwswmHM9BTYDV2FmcVuUJxBg7co9VgFzYNtqst+t0YBp3M3crygggNC7mHsv41Mgh7lSQSk4BiDTgxcu2UDt/rB/b16fLsYX6NMn7xR5jeENV68QrDaBZ8u28PWP+LUGfJ2+nd4EU2eVJMLZL50vXI4cLZGH1JF/EbdNuHho= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768965272; c=relaxed/simple; bh=X8BWzLz0NQml6tqdMPSbg+b4rHwh9sI17KZZ8UKZA3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a6Yo8gvZI8dQUYevxMDw7+IEpPExBPmJOTLXUAWGV8x9zXM8tl88NO+VbzPyAsoIO+hxcBn5BCM0eU160MbhUmRakxoY/y7oMOFkB7xGvnn7TFLC54LlG4Ff9FezmfH813/qVts/0o+6cOxx9DdeC0RNO8PXS/CD9Rnv4kHPClc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fCoLQd4X; 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="fCoLQd4X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F999C16AAE; Wed, 21 Jan 2026 03:14:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768965271; bh=X8BWzLz0NQml6tqdMPSbg+b4rHwh9sI17KZZ8UKZA3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fCoLQd4X7GWoGBB3BpUHgiQsjPJkXcMSKEuiU0IMYcHhKazNBSNR9lSEhkqW3E5qE BP264TU5b1LCc1WseqzKjxkc5Rg8Fx4bslzq60TvDhGWXQpfnwM/aehEYVqyQYZu/P Z5/cBhWF0MiBLne92fLEE4eJuG3T4pVY05ehqrvoq87bsEDkED9FSqvfEuKAkRPzZY CJ7w/XCJsirZRyVdPKBdsOW8aAYs6J2+gNXLiUpVSvXVR68slVya+EerDPPuJ3CywR jAjXVk7rj1I6XeY/KxVLjmBeL3vGnQsAyisgirgfbX43PKiZcQd07FAUYY5HMr2jZ0 wf2ar2TcOc37w== From: Sasha Levin To: stable@vger.kernel.org Cc: Ryan Roberts , Alexander Potapenko , Dmitriy Vyukov , Marco Elver , Andrew Morton , Sasha Levin Subject: [PATCH 6.12.y] mm: kmsan: fix poisoning of high-order non-compound pages Date: Tue, 20 Jan 2026 22:14:29 -0500 Message-ID: <20260121031429.1186608-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026012026-varying-grappling-04b4@gregkh> References: <2026012026-varying-grappling-04b4@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Ryan Roberts [ Upstream commit 4795d205d78690a46b60164f44b8bb7b3e800865 ] kmsan_free_page() is called by the page allocator's free_pages_prepare() during page freeing. Its job is to poison all the memory covered by the page. It can be called with an order-0 page, a compound high-order page or a non-compound high-order page. But page_size() only works for order-0 and compound pages. For a non-compound high-order page it will incorrectly return PAGE_SIZE. The implication is that the tail pages of a high-order non-compound page do not get poisoned at free, so any invalid access while they are free could go unnoticed. It looks like the pages will be poisoned again at allocation time, so that would bookend the window. Fix this by using the order parameter to calculate the size. Link: https://lkml.kernel.org/r/20260104134348.3544298-1-ryan.roberts@arm.com Fixes: b073d7f8aee4 ("mm: kmsan: maintain KMSAN metadata for page operations") Signed-off-by: Ryan Roberts Reviewed-by: Alexander Potapenko Tested-by: Alexander Potapenko Cc: Dmitriy Vyukov Cc: Dmitry Vyukov Cc: Marco Elver Cc: Ryan Roberts Cc: Signed-off-by: Andrew Morton [ Adjust context ] Signed-off-by: Sasha Levin --- mm/kmsan/shadow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c index 9c58f081d84fc..0327001b2b0ec 100644 --- a/mm/kmsan/shadow.c +++ b/mm/kmsan/shadow.c @@ -208,7 +208,7 @@ void kmsan_free_page(struct page *page, unsigned int order) return; kmsan_enter_runtime(); kmsan_internal_poison_memory(page_address(page), - page_size(page), + PAGE_SIZE << order, GFP_KERNEL, KMSAN_POISON_CHECK | KMSAN_POISON_FREE); kmsan_leave_runtime(); -- 2.51.0