From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-180.mta1.migadu.com (out-180.mta1.migadu.com [95.215.58.180]) (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 46F183F4DCC for ; Tue, 2 Jun 2026 14:26:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780410378; cv=none; b=YWC9bz+y4csYirzrk0fIBjZ+bxb5uu8EzVeGWTjKNjkGV3ScPBz2q0nF8CP2lXkBKkfHNlED/vqwCJ6JcN/KvALxW+uRKy3/efROIiNvdv/CjbNLQZz/1gdoLrdXsZf7pozUXqHuR9gD3dCnAloOaBaDsiSQMfVDHS0BD3/u7FI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780410378; c=relaxed/simple; bh=C88lGAINIFP+1Ky7ku+04w6HD7zfMD64jYRRFDOdK/A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fdrsq+ItsEo/q4Ah/v1zGf1Begrvc4alTgNa9thzNK+kMRA+c428DQzAuXw8zUEZKetC01bDDviz0rYtBuad6w75Ejvf7uhff6hI1Ku1W3xaX6Btx/Jsshu36fEWCsecC+H/y8Bha04gHTg+LxBUawO4dyK48wj+0eYGn3kRqnQ= 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=l+oMCYbo; arc=none smtp.client-ip=95.215.58.180 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="l+oMCYbo" 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=1780410375; 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: in-reply-to:in-reply-to:references:references; bh=+sVKInhmZvUV0YIB7MuEGVbtRZhztIPVEWbwWdNoYq4=; b=l+oMCYboba/geZJscTiEbt3R5wKJH/gWrBwfaaMUczY5D8oVKSRZbuqBGTt/mYSh7JPepP OWNUKECfDjwTc2H4HfjV/EyE9Wr+XjwxzpeDRUKgue9/utl8oF9Sa0oqFr1XqALh/yz7FZ +RSw55gpt38pM6CfyBfSjdC6n3n2gBg= From: Usama Arif To: Andrew Morton , david@kernel.org, chrisl@kernel.org, kasong@tencent.com, ljs@kernel.org, ziy@nvidia.com Cc: ying.huang@linux.alibaba.com, Baoquan He , willy@infradead.org, youngjun.park@lge.com, hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, alex@ghiti.fr, kas@kernel.org, baohua@kernel.org, dev.jain@arm.com, baolin.wang@linux.alibaba.com, npache@redhat.com, Liam R. Howlett , ryan.roberts@arm.com, Vlastimil Babka , lance.yang@linux.dev, linux-kernel@vger.kernel.org, nphamcs@gmail.com, shikemeng@huaweicloud.com, kernel-team@meta.com, Usama Arif Subject: [v2 03/16] fs/proc: use softleaf_has_pfn() in pagemap PMD walker Date: Tue, 2 Jun 2026 07:24:11 -0700 Message-ID: <20260602142537.198755-4-usama.arif@linux.dev> In-Reply-To: <20260602142537.198755-1-usama.arif@linux.dev> References: <20260602142537.198755-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 pagemap_pmd_range_thp() assumes that every non-present PMD is a migration entry and unconditionally calls softleaf_to_page(). This will crash on any non-present PMD type that does not encode a PFN, such as the upcoming PMD-level swap entries. Guard the page lookup with softleaf_has_pfn(), matching how pte_to_pagemap_entry() already handles non-present PTEs. Acked-by: David Hildenbrand (Arm) Signed-off-by: Usama Arif --- fs/proc/task_mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index d32408f7cd5e..1fb5acd88ad0 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -2129,7 +2129,8 @@ static int pagemap_pmd_range_thp(pmd_t *pmdp, unsigned long addr, flags |= PM_SOFT_DIRTY; if (pmd_swp_uffd_wp(pmd)) flags |= PM_UFFD_WP; - page = softleaf_to_page(entry); + if (softleaf_has_pfn(entry)) + page = softleaf_to_page(entry); } if (page) { -- 2.52.0