Re: [PATCH v3 25/40] mm/vma: enforce that only kernel-owned mappings may set VMA_IO_BIT
From: "Zi Yan" <ziy@nvidia.com>
Date: 2026-09-29 02:12:19
Also in:
bpf, dri-devel, fuse-devel, kvm, kvm-riscv, kvmarm, linux-arch, linux-doc, linux-fsdevel, linux-mm, linux-perf-users, linux-rdma, linux-riscv, linux-s390, linux-scsi, linux-sound, linux-trace-kernel, linux-usb, linuxppc-dev, lkml, selinux, sparclinux
On Thu Sep 17, 2026 at 12:22 PM EDT, Lorenzo Stoakes (ARM) wrote:
quoted hunk ↗ jump to hunk
It makes no sense for a mapping whose contents the kernel does not own to
specify that the range is MMIO.
Prior to this patch, all in-tree drivers which did so have been updated
such that they are marked as kernel-owned. The check WARNs and fails the
mmap for any out-of-tree driver that still sets VMA_IO_BIT without a kernel
mapping.
No functional change intended for in-tree code.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
mm/vma.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/vma.c b/mm/vma.c
index 1db8b218fe64..56a0cd154419 100644
--- a/mm/vma.c
+++ b/mm/vma.c
@@ -2787,6 +2787,12 @@ static int mmap_validate_vma_flags(const vma_flags_t *flags)
return -EINVAL;
#endif
+ if (!vma_flags_test_any(flags, VMA_PFNMAP_BIT, VMA_MIXEDMAP_BIT)) {
I thought why not just using vma_flags_is_kernel_owned(), then realize
that function is still checking VMA_IO_BIT. And you convert it in the
next patch.
LGTM.
Reviewed-by: Zi Yan <ziy@nvidia.com>
--
Best Regards,
Yan, Zi