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].
This series is based on tree [2].
Changes in this v3 as compared with v2(Based on suggestions from Kevin):
1) Implemented all suggestion from Kevin on V2 version. However, suggestion to use (unsigned long __user *) instead of user_uintptr_t was not done due to not much benefits and lack of time.
2) vm_mmap() now takes address as unsigned long instead of user_uintptr_t.
3) get_unmapped_area() now checks if address range falling within reservation in case of MAP_FIXED address.
4) New function check_pcuabi_params() added to check parameters sanity in mmap and mremap syscalls.
5) Several fixes and cleanups.
6) Patch 3, 24 and 25 are new patches.
Testing:
1) All tests by Chaitanya in v8 selftests [3] passes. 2) Purecap/Compat Busybox boot passes after adding [WIP] patches present in [4].
The whole series can be found here [4].
[1]: https://git.morello-project.org/morello/kernel/linux/-/wikis/Morello-pure-ca... [2]: https://git.morello-project.org/morello/kernel/linux morello/next [3]: https://git.morello-project.org/chaitanya_prakash/linux.git review/purecap_mmap_testcases_v8 [4]: https://git.morello-project.org/amitdaniel/linux.git review/purecap_mm_reservation_v3
Thanks, Amit Daniel
Amit Daniel Kachhap (25): uapi: errno.h: Introduce PCuABI memory reservation error linux/sched/coredump.h: Add MMF_PCUABI_RESERV mm flag linux/user_ptr.h: Add a typedef user_ptr_perms_t mm/cap_addr_mgmt: Add capability reservation interfaces in VMA linux/user_ptr.h: Add two helpers to operate on user pointers lib/user_ptr: Add helpers to be used by mm syscalls mm/mmap: Modify get free unmapped address space management code mm/(mmap,mremap): Add PCuABI reservation during VMA operation mm/mmap: Add reservation constraints in mmap/munmap parameters mm/mremap: Add reservation constraints in mremap parameters 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 mm/mmap: Disable MAP_GROWSDOWN mapping flag for PCuABI uapi: mman-common.h: Macros for maximum capability permissions lib/user_ptr: Add user pointer permission helpers for PCuABI arm64: user_ptr: Implement morello capability permission helpers 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 fs/binfmt_elf: Add PCuABI reservation constraints ipc/shm: Add the PCuABI reservation constraints arm64: vDSO: Add appropriate capability bounds
Documentation/core-api/user_ptr.rst | 28 +++ arch/Kconfig | 3 + arch/arm64/Kconfig | 1 + arch/arm64/include/asm/elf.h | 5 +- arch/arm64/include/asm/mmu.h | 2 +- arch/arm64/include/asm/user_ptr.h | 34 ++++ arch/arm64/kernel/signal.c | 2 +- arch/arm64/kernel/vdso.c | 29 +++- fs/binfmt_elf.c | 78 ++++++--- include/linux/cap_addr_mgmt.h | 227 +++++++++++++++++++++++++ include/linux/mm.h | 16 +- include/linux/mm_types.h | 9 + include/linux/sched/coredump.h | 2 + include/linux/shm.h | 4 +- include/linux/user_ptr.h | 101 +++++++++++ include/uapi/asm-generic/errno.h | 2 + include/uapi/asm-generic/mman-common.h | 6 + io_uring/advise.c | 2 +- ipc/shm.c | 27 +-- kernel/fork.c | 3 + lib/user_ptr.c | 74 ++++++++ mm/Makefile | 1 + mm/cap_addr_mgmt.c | 150 ++++++++++++++++ mm/damon/vaddr.c | 2 +- mm/internal.h | 2 +- mm/madvise.c | 27 ++- mm/mincore.c | 46 ++++- mm/mlock.c | 36 +++- mm/mmap.c | 188 +++++++++++++++++--- mm/mprotect.c | 26 ++- mm/mremap.c | 98 ++++++++--- mm/msync.c | 13 +- mm/util.c | 9 +- 33 files changed, 1119 insertions(+), 134 deletions(-) create mode 100644 arch/arm64/include/asm/user_ptr.h create mode 100644 include/linux/cap_addr_mgmt.h create mode 100644 mm/cap_addr_mgmt.c