From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 5DDBB175A6E for ; Sun, 5 Jul 2026 13:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783257167; cv=none; b=abx33ztj5bjaGNof1Hb1uT+3Yb5+ZnGjklq5Hj84XNAXuCp4s4SjcszhNMqm8QrM058AWN9XPqNTRKBy6AoWob4mhM0NcAjq58sRPPr6f8LElEVM+h9NtE8MpOVo6R+j4Ksmkv7HhL17gGXfhqPrVE258EfOlgs3IMw9rmvgXh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783257167; c=relaxed/simple; bh=xBJCO7xfryXizy8Sg8ywT2QOioVBZWHrMfUPgub/Cmg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=h4g+PxYPEyI3qn0y0HGy4mr60m80DCnGnlC9vAztlrEzpyPTyTsa/5+hpJ1NRkP9kjT8sG0d7A9SUbg11votqmIpe/DeZjtfSmW419XpWQm7H9Fec5GEiPbLGAYVqkCZvhs7XYrzpesvWafama7mGtF6AaK1CcpcfV7MCEwFhF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QxYPmnjm; arc=none smtp.client-ip=91.218.175.172 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) header.d=linux.dev header.i=@linux.dev header.b="QxYPmnjm" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1783257161; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=loMni5jHoSKoKTYnGMM9Px3Q7ehOwibtPYphjTw/wfk=; b=QxYPmnjmWqUc9bWzP+SAOW1YFUYgBcRnaLa5sD1BrzblhJRmCuARcLogD+3e9l2/ZyLGIp I93nDkr/L9h5WiOfwXJaJZ0vm+nYaCC0EGuh92ZV5wuVNrXJKYskrEB6X3gNSkV+H5U4Vp waURCoiae58uMAoNQKF6y8Qw+EpMZeg= From: Usama Arif To: 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, ljs@kernel.org, npache@redhat.com, ryan.roberts@arm.com, usama.arif@linux.dev, ziy@nvidia.com, aarcange@redhat.com, shakeel.butt@linux.dev, hannes@cmpxchg.org, riel@surriel.com, kernel-team@meta.com Cc: sashiko-bot Subject: [PATCH] userfaultfd: wait on source PMD during UFFDIO_MOVE Date: Sun, 5 Jul 2026 06:12:31 -0700 Message-ID: <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-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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. 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 --- 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