aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/mm/vm_util.h
diff options
context:
space:
mode:
authorThomas Weißschuh <[email protected]>2025-01-14 16:06:48 +0000
committerAndrew Morton <[email protected]>2025-01-26 04:22:44 +0000
commit3bd6137220bb5cf4114d038cf90cb20375b31124 (patch)
treee8a6e14b5a10f676cc6f24d314ebfc11342cf181 /tools/testing/selftests/mm/vm_util.h
parentselftests/mm: vm_util: split up /proc/self/smaps parsing (diff)
downloadkernel-3bd6137220bb5cf4114d038cf90cb20375b31124.tar.gz
kernel-3bd6137220bb5cf4114d038cf90cb20375b31124.zip
selftests/mm: virtual_address_range: avoid reading from VM_IO mappings
The virtual_address_range selftest reads from the start of each mapping listed in /proc/self/maps. However not all mappings are valid to be arbitrarily accessed. For example the vvar data used for virtual clocks on x86 [vvar_vclock] can only be accessed if 1) the kernel configuration enables virtual clocks and 2) the hypervisor provided the data for it. Only the VDSO itself has the necessary information to know this. Since commit e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping") the virtual clock data was split out into its own mapping, leading to EFAULT from read() during the validation. Check for the VM_IO flag as a proxy. It is present for the VVAR mappings and MMIO ranges can be dangerous to access arbitrarily. Link: https://lkml.kernel.org/r/20250114-virtual_address_range-tests-v4-4-6fd7269934a5@linutronix.de Reported-by: kernel test robot <[email protected]> Closes: https://lore.kernel.org/oe-lkp/[email protected] Fixes: e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping") Fixes: 010409649885 ("selftests/mm: confirm VA exhaustion without reliance on correctness of mmap()") Signed-off-by: Thomas Weißschuh <[email protected]> Suggested-by: David Hildenbrand <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Acked-by: David Hildenbrand <[email protected]> Cc: Anshuman Khandual <[email protected]> Cc: Dev Jain <[email protected]> Cc: Shuah Khan (Samsung OSG) <[email protected]> Cc: Thomas Gleixner <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
Diffstat (limited to 'tools/testing/selftests/mm/vm_util.h')
-rw-r--r--tools/testing/selftests/mm/vm_util.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/testing/selftests/mm/vm_util.h b/tools/testing/selftests/mm/vm_util.h
index 2eaed8209925..b60ac68a9dc8 100644
--- a/tools/testing/selftests/mm/vm_util.h
+++ b/tools/testing/selftests/mm/vm_util.h
@@ -53,6 +53,7 @@ int uffd_unregister(int uffd, void *addr, uint64_t len);
int uffd_register_with_ioctls(int uffd, void *addr, uint64_t len,
bool miss, bool wp, bool minor, uint64_t *ioctls);
unsigned long get_free_hugepages(void);
+bool check_vmflag_io(void *addr);
/*
* On ppc64 this will only work with radix 2M hugepage size