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 953E33F4105; Mon, 25 May 2026 17:05:05 +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=1779728706; cv=none; b=oLIzrtbFrgRLi81GfRRv/pAt1bF5xJu7shgTxTDqKrRu9tJ3nRsLUOu00gc6k/DiKPGlOwN4AjlTYgEc7OS7LJ7RPzKQFr5Yahc1qO2XlLk02lQd+b92Uyjn2WdYt/nldVtqv5lr7DjSpICqqThiffI9DSF6+ve9SKkk1d5V0lM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779728706; c=relaxed/simple; bh=urwakPmJnm+0fEh4k2xxmRlHPp0R7XfaUpFyDzVgSNM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=L7LYIu921NGInWXyCIp+zHxgUjdmNg8opmYovXZ8JrCPpYvrk9X6lhTPDV2i+uMwhng89bRWI94bLiZCQ4M2FBB+AbTi1zttR+Hwny8/MxdSl5VegFgzI2XqCDYbwZOnTi0MqqtXxCj6XmP4HZ+OZZ7MzOVjWE178WVnbsLSL4U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HFaDl+ss; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HFaDl+ss" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C80A1F000E9; Mon, 25 May 2026 17:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779728705; bh=z5IOJhY5s4BFHeiUSPpmIVhS2IhxEwNZmsrIdtBR4Hk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=HFaDl+sscIJhvLTUeOqNibUngqgyF1Xx3moBnJ9k+a+eRXJhK0W0nogcjmSdMkXB/ TqTBD1L/E0Cw725+bjsRF+Fd1980xVK5KutNv/caIad7CUZCHpduamW/kByoiRlM2W ogqUTAyl+tQHaD+bmPk0jTIJYMeBELqp9A58JHaxS++9pKwkkUJW6fIcFbEVhGWAdI psdTbrTt3qlkQXW5X+viMG5tpFLcwXil4MrD5azDubEDmB5aPs2FEAl6gYdpabTnCr BghyOnwcKkRBCJBRg5PFvgKJqgaIlE/yWhtqUFnQ52tLnwYD+naKQB76rzIcsEzeW0 3nMiVlIh8qidQ== Date: Mon, 25 May 2026 19:04:58 +0200 From: "Oscar Salvador (SUSE)" To: Muchun Song Cc: Muchun Song , Oscar Salvador , Andrew Morton , David Hildenbrand , Kiryl Shutsemau , linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] mm/hugetlb_vmemmap: fix incorrect vmemmap restore in rollback Message-ID: References: <20260525025213.2229628-1-songmuchun@bytedance.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260525025213.2229628-1-songmuchun@bytedance.com> On Mon, May 25, 2026 at 10:52:13AM +0800, Muchun Song wrote: > vmemmap_restore_pte() rebuilds restored vmemmap pages from a > tail-page template derived from compound_head(). This is wrong when the > current PTE already maps a page whose contents are not tail-page > metadata. > > In the rollback path of vmemmap_remap_free(), the first restored PTE is > backed by vmemmap_head and contains head-page metadata. Reconstructing > that page from a tail-page template overwrites the head-page state and > corrupts the restored vmemmap page. > > Fix this by copying the full page from the page currently mapped by the > PTE. Also pass vmemmap_tail to the rollback walk so only PTEs backed by > the shared tail page are restored, while the head PTE remains mapped to > vmemmap_head. Add VM_WARN_ON_ONCE() checks for unexpected cases. > > Fixes: c0b495b91a47 ("mm/hugetlb: refactor code around vmemmap_walk") > Cc: stable@vger.kernel.org > Signed-off-by: Muchun Song Acked-by: Oscar Salvador (SUSE) -- Oscar Salvador SUSE Labs