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 C55CD37475B for ; Sat, 11 Jul 2026 08:13:57 +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=1783757638; cv=none; b=qdba7mihObYlTZqdutdN4Gw6qeppruWKmjz+Utu9U5y8GjmP3VpwO5Vxt6AjTSxmlSt/1/R0ffSon1+AEKiJu8mMoLAp5lwzze8hRsvBglY00xHmL+JZ4udebJ6tIuMa+5SlZ+PajSbRoTvWNNkeI8/4vdPPGFixyTzlJY+ZGPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783757638; c=relaxed/simple; bh=PFPkNViPhCH7+ngRWjqgGnkB61/j5qoDgfJokuhvrFo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FUzqCQLzlmO9zQ7CgXSpJh0AZ455XYT6wRaf3XGau2o/5C7gHmtpPTB7h2fLpNtfo1Ji75Q+N0/LKMwMroqalWh3QyZu55+Az86W2/TMrvct29DYF7XVWbHwAL0Kaln4sbkPRs2Qrzb1y1DCb5xqMH1nu3E5wvOdY3zJsG/YzD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FzsOqxB7; 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="FzsOqxB7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6B8901F000E9; Sat, 11 Jul 2026 08:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783757637; bh=fL+OBgv9MiT2Y8LAZqP3EBv16Se8dNO3kHDIpd+tmoY=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=FzsOqxB7yjmk8r6CDB1CdPdVSUYM1meVTyG+V/ZCtyKyIxP8e+cqryo0Fr21Vhz3f 66ASdWOyx/Ehv096Cid8xYzpM1MdYGKW5fuzjrbhydwKrjLdjaqZDw9vHOM8JXFOfs rUOUC/QVGHsS23/kpeM0sWl//ckJbBvai8EZtdI0+4DHZ+IG0zxx96PzUqIdqj698B 2dqdoTX2/qf7Ej4kKrxD7mipggBuyjgxRIeyg1015ogfpjPZnoEdMcgkn7A3tZovYc trvndunLLmVIFkvPHKnMACJkgKn7DEYriLNwEC9kSWhUwV09GEOaDBA6/y86oy5VPK gSCC9MZQaC7Sw== Date: Sat, 11 Jul 2026 09:13:44 +0100 From: Lorenzo Stoakes To: Usama Arif Cc: Andrew Morton , baohua@kernel.org, baolin.wang@linux.alibaba.com, david@kernel.org, dev.jain@arm.com, lance.yang@linux.dev, liam@infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, npache@redhat.com, ryan.roberts@arm.com, ziy@nvidia.com, aarcange@redhat.com, shakeel.butt@linux.dev, hannes@cmpxchg.org, riel@surriel.com, kernel-team@meta.com, sashiko-bot Subject: Re: [PATCH] userfaultfd: wait on source PMD during UFFDIO_MOVE Message-ID: References: <20260705131231.1499198-1-usama.arif@linux.dev> 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: <20260705131231.1499198-1-usama.arif@linux.dev> On Sun, Jul 05, 2026 at 06:12:31AM -0700, Usama Arif wrote: > move_pages_huge_pmd() snapshots src_pmdval under src_ptl, drops the lock, > and, for migration entries, waits with pmd_migration_entry_wait(). > > Passing &src_pmdval is wrong. pmd_migration_entry_wait() must lock and > re-read the real page-table PMD; on split-PMD-lock kernels, a stack > address also resolves to the wrong lock. softleaf_entry_wait_on_locked() > then waits without a folio reference, which is safe only while serialized > against migration-entry removal by the real PT lock. Yikes! > > Pass src_pmd, matching __handle_mm_fault() and hmm_vma_walk_pmd(). > > Reported-by: sashiko-bot > Link: https://sashiko.dev/#/patchset/20260703173903.3789516-1-usama.arif%40linux.dev?part=8 > Fixes: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI") > Signed-off-by: Usama Arif LGTM so: Reviewed-by: Lorenzo Stoakes > --- > mm/huge_memory.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/huge_memory.c b/mm/huge_memory.c > index bdd8635922f9..c0892cc533a9 100644 > --- a/mm/huge_memory.c > +++ b/mm/huge_memory.c > @@ -2775,7 +2775,7 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm > if (!pmd_trans_huge(src_pmdval)) { > spin_unlock(src_ptl); > if (pmd_is_migration_entry(src_pmdval)) { > - pmd_migration_entry_wait(mm, &src_pmdval); > + pmd_migration_entry_wait(mm, src_pmd); > return -EAGAIN; > } > return -ENOENT; > -- > 2.53.0-Meta > Cheers, Lorenzo