From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793094448; b=AUS9DMgOgdEastcWV5QIarGtcFzdi12zmQf2PCRpNAIpfdRlF4DzS0rvy2SJnyOKgGZu fjBFcA+Hkw4p52qp8mgqv6T9Q0KaXwOxf7mcq8BCH4da6MIN3kp0ieEpVT3WRZ/YMymX8 TEjDI5K1piytJzprlzCsb3VRvsx/ZMSUPQJrWyXAZ7J3glOTW897udDie5RMNr4JMRkG4 Fr8/8ZXRTFrYiNuyAAFl8Ivmz3ig/2ZP8H6575iQQ0nG43PGTVc3AaVUvFLKiGHyYruVG ArfpYCCpYZr+Z/Gvav41xHt2kHV8lGiAgyFnT5zJc0F7hqMKpvfV5kOhcYFDeYNpaXg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793094448; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=vkRbVEYH/IpHfx5799qbaRy/Rz2dM/B52EsX44m71XA=; b=5TFisYSDG7bMrVlxaGnHnn2PEA72qmp2f2Qc1ZCzokNXb06PngaQMkN8gdV7Mi+5qjt/ KmtyQWyAZtrX/w0YWVg2vSZRr5NGctI+qTXuT5N7DhcI6PAt8lhAwyPclFbrticSBNnOU 4FSYBiVDWF14PB428hqPgYHf1/fshGJNQ46PGE6byjW75pspeZeHUJ8LeiVMxeV7xV5nl SJFRImhpPuE83yp8vZ6lh5FAexMMul4dssdHqPUizf1lYl3VzRolBX+8Xf1EukkPG46hT 73BCSB/khhWrNCtwubj2AWapdaCjK1FkI6oN4ykf/creDKmelBkDkIcugO71wo4TKmQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="ayiRgza/"; arc=none smtp.remote-ip=91.218.175.176 Received: from mta0.migadu.com (out-176.mta0.migadu.com [91.218.175.176]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19773606A31F for ; Tue, 27 Oct 2026 09:47:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 19773606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=ayiRgza/ X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=cPhbwrLxrBeT9JsGny5RJdPlGOD/1Ehjle0H8Uiu/2w=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793094445; v=1; x=1793699245; b=ayiRgza/GxxmiVI9rgFsykUvChZWAtRADU5um6RBV71Km8e1c4L5jy/cPURegap7ZDCx6IFM bX37cSFeF5CycBHA7SWLRaiZAOMH3jO6XedepEVuCZJjsKpGXjjrmoB32a0QwIDJDb6RMbWFhbi OUBk4/abpc9TguYGICF4Oc9k= X-Envelope-To: linux-kernel@vger.kernel.org Received: by mta12.migadu.com with ESMTPS id 4eebca5cdaffa06c; Tue, 27 Oct 2026 09:47:24 +0000 X-Mizu-Trace-ID: 4eebca5cdaffa06c X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.100.1.1.12\)) Subject: Re: [PATCH 37/46] mm: fix deadlock of mremap() against UFFDIO_MOVE From: Muchun Song In-Reply-To: <20261027-fixes_core-v1-37-6f74bec9a5bb@kernel.org> Date: Tue, 27 Oct 2026 17:46:54 +0800 Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Baolin Wang , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook , Peter Zijlstra , Jann Horn , Pedro Falcato , Hugh Dickins , Pasha Tatashin , Pratyush Yadav , "Matthew Wilcox (Oracle)" , Jan Kara , Zi Yan , Lance Yang , Rik van Riel , Harry Yoo , Alistair Popple , Nico Pache , Ryan Roberts , Dev Jain , Usama Arif , Kiryl Shutsemau , Matthew Brost , John Hubbard , Peter Xu , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Oscar Salvador , Minchan Kim , Xu Xin , Chengming Zhou , Chris Li , Kemeng Shi , Nhat Pham , Youngjun Park , Gregory Price , Joshua Hahn , Rakie Kim , Ying Huang , Jason Gunthorpe , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, Chris Mason , stable@vger.kernel.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20261027-fixes_core-v1-0-6f74bec9a5bb@kernel.org> <20261027-fixes_core-v1-37-6f74bec9a5bb@kernel.org> To: "David Hildenbrand (Arm)" X-Mailer: Apple Mail (2.3901.100.1.1.12) > On Oct 27, 2026, at 07:17, David Hildenbrand (Arm) = wrote: >=20 > From: Chris Mason >=20 > With per-VMA locks, UFFDIO_MOVE can run concurrently with mremap() > on different VMAs in the same mm. Those VMAs can share page tables, so > both operations can acquire the same pair of page-table locks. >=20 > UFFDIO_MOVE orders the locks by address, while mremap() takes the = source > lock first. These conflicting orders can deadlock; mremap() holding > mmap_lock for writing no longer helps. >=20 > Move double_pt_lock() and double_pt_unlock() to mm/internal.h and use > them for all page-table moves in mremap(). Preserve the source entry > checks after acquiring both locks. Remove the comments claiming that > exclusive mmap_lock makes lock ordering irrelevant. >=20 > In move_ptes(), make sure to just recheck source and destination PMD > after taking the locks and drop the overly-long comment. >=20 > Fix generated by an LLM and sent by Chris Mason in private. >=20 > Fixes: 867a43a34ff8 ("userfaultfd: use per-vma locks in userfaultfd = operations") > Cc: stable@vger.kernel.org > Signed-off-by: Chris Mason > [ david: use new helpers consistently; simplify description and = comments; > move_ptes() fixup ] > Signed-off-by: David Hildenbrand (Arm) Acked-by: Muchun Song Thanks.