mm: Care about shadow stack guard gap when getting an unmapped area
Status from this message: [merged mm-stable] mm-care-about-shadow-stack-guard-gap-when-getting-an-unmapped-area.patch removed from -mm tree
Get series with b4
b4 am 20240904-mm-generic-shadow-stack-guard-v2-0-a46b8b6dc0ed@kernel.org change-id 20240830-mm-generic-shadow-stack-guard-5bc5b8d0e95dVersions newest first
- v2 Latest3 patches 0 repliesApplied 3/3
- v13 patches 14 repliesSuperseded
Changes in v2 from the cover letter
- Add comment to stack_guard_placement()
- Build fixes for xtensa and MIPS.
- Link to v1: https://lore.kernel.org/r/20240902-mm-generic-shadow-stack-guard-v1-0-9acda38b3dd3@kernel.org
Patches in v2 All 3 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | mm: Make arch_get_unmapped_area() take vm_flags by defaultarch/ arch/ arch/ +15 more | +51 | 0 replies | Applied |
| 2/3 | mm: Pass vm_flags to generic_get_unmapped_area()arch/ include/ mm/ | +10 | 0 replies | Applied |
| 3/3 | mm: Care about shadow stack guard gap when getting an unmapped areamm/ | +14 | 0 replies | Applied |
Reviews trailers per patch
All 3 patches have a Reviewed-by or Acked-by.
| Patch | Lorenzo Stoakes | Liam R. Howlett | Helge Deller | Michael Ellerman |
|---|---|---|---|---|
| 1/3 | A-b | R-b | A-b | |
| 2/3 | A-b | R-b | A-b | |
| 3/3 | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 4 reviewers.
Cover letter [PATCH v2 0/3] mm: Care about shadow stack guard gap when getting an unmapped area
As covered in the commit log for c44357c2e76b ("x86/mm: care about shadow stack guard gap during placement") our current mmap() implementation does not take care to ensure that a new mapping isn't placed with existing mappings inside it's own guard gaps. This is particularly important for shadow stacks since if two shadow stacks end up getting placed adjacent to each other then they can overflow into each other which weakens the protection offered by the feature.
On x86 there is a custom arch_get_unmapped_area() which was updated by the above commit to cover this case by specifying a start_gap for allocations with VM_SHADOW_STACK. Both arm64 and RISC-V have equivalent features and use the generic implementation of arch_get_unmapped_area() so let's make the equivalent change there so they also don't get shadow stack pages placed without guard pages. The arm64 and RISC-V shadow stack implementations are currently on the list:
https://lore.kernel.org/r/20240829-arm64-gcs-v12-0-42fec94743
https://lore.kernel.org/lkml/[email protected]/
Given the addition of the use of vm_flags in the generic implementation we also simplify the set of possibilities that have to be dealt with in the core code by making arch_get_unmapped_area() take vm_flags as standard. This is a bit invasive since the prototype change touches quite a few architectures but since the parameter is ignored the change is straightforward, the simplification for the generic code seems worth it.
Changes in v2:
- Add comment to stack_guard_placement()
- Build fixes for xtensa and MIPS.
- Link to v1: https://lore.kernel.org/r/20240902-mm-generic-shadow-stack-guard-v1-0-9acda38b3dd3@kernel.org
---
Mark Brown (3):
mm: Make arch_get_unmapped_area() take vm_flags by default
mm: Pass vm_flags to generic_get_unmapped_area()
mm: Care about shadow stack guard gap when getting an unmapped area
arch/alpha/kernel/osf_sys.c | 2 +- arch/arc/mm/mmap.c | 3 ++- arch/arm/mm/mmap.c | 7 ++--- arch/csky/abiv1/mmap.c | 3 ++- arch/loongarch/mm/mmap.c | 5 ++-- arch/mips/mm/mmap.c | 5 ++-- arch/parisc/kernel/sys_parisc.c | 5 ++-- arch/parisc/mm/hugetlbpage.c | 2 +- arch/powerpc/mm/book3s64/slice.c | 10 ++++--- arch/s390/mm/mmap.c | 4 +-- arch/sh/mm/mmap.c | 5 ++-- arch/sparc/kernel/sys_sparc_32.c | 2 +- arch/sparc/kernel/sys_sparc_64.c | 4 +-- arch/x86/include/asm/pgtable_64.h | 1 - arch/x86/kernel/sys_x86_64.c | 21 +++------------ arch/xtensa/kernel/syscall.c | 3 ++- include/linux/sched/mm.h | 27 +++++++------------ mm/mmap.c | 55 +++++++++++++++++++-------------------- 18 files changed, 75 insertions(+), 89 deletions(-)
---
base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
change-id: 20240830-mm-generic-shadow-stack-guard-5bc5b8d0e95d
Best regards,
Signature · 1 line
Mark Brown <[email protected]>