diff mbox series

mm/vmalloc: fix mischeck pfn valid in vmap_pfns

Message ID 20250312061513.1126496-1-link@vivo.com (mailing list archive)
State New
Headers show
Series mm/vmalloc: fix mischeck pfn valid in vmap_pfns | expand

Commit Message

Huan Yang March 12, 2025, 6:15 a.m. UTC
When invoke vmap_pfns, it call vmap_pfn_apply to set pfn into pte.
It check pfn is valid, if true then warn and return.

This is a mischeck, actually we need set a valid pfn into pte, not an
invalid pfn.

This patch fix it.

Signed-off-by: Huan Yang <link@vivo.com>
Reported-by: Bingbu Cao <bingbu.cao@linux.intel.com>
Closes: https://lore.kernel.org/dri-devel/eb7e0137-3508-4287-98c4-816c5fd98e10@vivo.com/T/#mbda4f64a3532b32e061f4e8763bc8e307bea3ca8
Fixes: b3f78e749865 ("mm: vmalloc must set pte via arch code")

---
 mm/vmalloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig March 12, 2025, 6:18 a.m. UTC | #1
On Wed, Mar 12, 2025 at 02:15:12PM +0800, Huan Yang wrote:
> When invoke vmap_pfns, it call vmap_pfn_apply to set pfn into pte.
> It check pfn is valid, if true then warn and return.
> 
> This is a mischeck, actually we need set a valid pfn into pte, not an
> invalid pfn.

As just discussed this is wrong.  vmap_pfn is for mapping non-page
PFNs and the check is what enforces that.  What is the point of having
that detailed discussion if you just send the broken patch anyway with
a commit log not even acknowledging the facts?
diff mbox series

Patch

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 044af7088359..ebadb8ceeba7 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -3488,7 +3488,7 @@  static int vmap_pfn_apply(pte_t *pte, unsigned long addr, void *private)
 	unsigned long pfn = data->pfns[data->idx];
 	pte_t ptent;
 
-	if (WARN_ON_ONCE(pfn_valid(pfn)))
+	if (WARN_ON_ONCE(!pfn_valid(pfn)))
 		return -EINVAL;
 
 	ptent = pte_mkspecial(pfn_pte(pfn, data->prot));