Hi All,
This patch series introduces the mm reservation interface to manage the owning capability of the allocated addresses. This series adds reservation details in the VMA structure and different capability/reservation constraint checks. Looking for feedback regarding API names, directory structure etc.
Details about several rules implemented can be found in PCuABI spec here [1].
Changes in this v1 as compared with RFC v2:
1) Added mm specific purecap flag instead of vma specific.
2) Enabled vma merge/expansion with reservation limit checks.
3) Modified get_unmapped_area() to add overlap checks for fixed address.
4) Some code fixes and cleanups as suggested by Kevin.
Future works:
1) Users of vm_mmap/vm_munmap() i.e. filesystems, loaders, vdso, exec stack to be modified to preserve capability addresses. Some of these work in progress are hosted in [3] for reference. 2) Cover remaining memory addressing syscalls.
Testing:
1) All tests by Chaitanya in v3 selftests [2] passes. 2) Purecap/Compat Busybox boot passes after adding [WIP] patches present in [3].
The whole series can be found here [3].
[1]: https://git.morello-project.org/morello/kernel/linux/-/wikis/Morello-pure-ca... [2]: https://git.morello-project.org/chaitanya_prakash/linux.git review/purecap_mmap_testcases_v3 [3]: https://git.morello-project.org/amitdaniel/linux.git review/purecap_mm_reservation_v1
Thanks, Amit Daniel
Amit Daniel Kachhap (21): uapi: errno.h: Introduce PCuABI memory reservation error mm: Add MMF_PCUABI_RESERVE mm flag mm: Add capability reservation interfaces in vma for PCuABI mm/cap_addr_mgmt: Add capability constraint helpers for PCuABI mm,fs: Use address as user_uintptr_t in generic get_unmapped_area() mm/mmap: Modify unmapped address space management code for PCuABI mm: Add PCuABI reservation details during vma operation mm/mmap: Add reservation constraints in mmap/munmap parameters mm/mremap: Add reservation constraints in mremap syscall mm/mprotect: Add the PCuABI reservation constraints mm/madvise: Add the PCuABI reservation constraints mm/mlock: Add the PCuABI reservation constraints mm/msync: Add the PCuABI reservation constraints uapi: mman-common.h: Macros for maximum capability permissions mm/cap_addr_mgmt: Add capability permission helpers for PCuABI mm/cap_addr_mgmt: Reduce the maximum protection check impact mm/mmap: Disable MAP_GROWSDOWN mapping flag for PCuABI mm/mmap: Add capability permission constraints for PCuABI mm/mremap: Add capability permission constraints for PCuABI mm/mprotect: Add capability permission constraints for PCuABI mm/mincore: Add PCuABI reservation/capability constraints
arch/arm64/include/asm/cap_addr_mgmt.h | 22 ++ drivers/char/mem.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/proc/inode.c | 4 +- fs/ramfs/file-mmu.c | 2 +- include/linux/cap_addr_mgmt.h | 268 +++++++++++++++++++++++++ include/linux/cheri.h | 3 + include/linux/fs.h | 2 +- include/linux/huge_mm.h | 2 +- include/linux/mm.h | 39 +++- include/linux/mm_types.h | 7 +- include/linux/proc_fs.h | 2 +- include/linux/sched/coredump.h | 2 + include/linux/sched/mm.h | 8 +- include/linux/shmem_fs.h | 2 +- include/uapi/asm-generic/errno.h | 2 + include/uapi/asm-generic/mman-common.h | 6 + io_uring/advise.c | 2 +- io_uring/io_uring.c | 2 +- ipc/shm.c | 2 +- kernel/fork.c | 3 + mm/Makefile | 2 +- mm/cap_addr_mgmt.c | 261 ++++++++++++++++++++++++ mm/damon/vaddr.c | 2 +- mm/huge_memory.c | 2 +- mm/madvise.c | 29 ++- mm/mincore.c | 46 ++++- mm/mlock.c | 38 +++- mm/mmap.c | 250 ++++++++++++++++++++--- mm/mprotect.c | 29 ++- mm/mremap.c | 96 +++++++-- mm/msync.c | 16 +- mm/shmem.c | 4 +- mm/util.c | 12 +- 34 files changed, 1056 insertions(+), 115 deletions(-) create mode 100644 arch/arm64/include/asm/cap_addr_mgmt.h create mode 100644 include/linux/cap_addr_mgmt.h create mode 100644 mm/cap_addr_mgmt.c