Skip to content

arm64: Assorted GCS fixes

Catalin Marinas linux-arm-kernel 2 versions – Applied

Status from this message: Applied to arm64 (for-next/fixes), thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 4 repliesApplied
  2. v13 patches 10 repliesSuperseded

Changes in v2 from the cover letter

- I dropped the VM_NOHUGEPAGE patch from this series. I'll submit a separate one that also changes riscv and x86 for consistency.

- Added a gcs_page_prot variable to store the protection for the gcs page, somewhat closer to what we do with protection_map[]. There are other ways to implement this, e.g. using PTE_MAYBE_SHARED or starting from protection_map[] and replacing the PIE bits with those from _PAGE_GCS_RO.

- The PROT_NONE patch was updated to drop the NUMA migration reference (this path is not exercised in that case), mention mprotect() instead. In addition, it checks VM_ACCESS_FLAGS instead of VM_READ|VM_WRITE.

- Added kselftest for the GCS PROT_NONE case.

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3arm64: gcs: Do not set PTE_SHARED on GCS mappings if FEAT_LPA2 is enabledarch/arm64/include/asm/pgtable-prot.h arch/arm64/mm/mmap.c+6 -51 reply
2/3arm64: gcs: Honour mprotect(PROT_NONE) on shadow stack mappingsarch/arm64/mm/mmap.c+5 -11 reply
3/3kselftest: arm64: Check access to GCS after mprotect(PROT_NONE)tools/testing/selftests/arm64/signal/testcases/gcs_prot_none_fault.c+76 -01 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchMark BrownDavid Hildenbrand (Arm)
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/3] arm64: Assorted GCS fixes

A couple of GCS fixes and a corresponding kselftest. The first fix solves a kernel panic when LPA2 is present. The second ensures that the shadow stack is not accessible after mprotect(PROT_NONE). The test is fairly close to gcs_write_fault.c but performs a normal read from the shadow stack before and after mprotect(PROT_NOTE).

v1 here:

https://lore.kernel.org/all/[email protected]/

Changes since v1:

- I dropped the VM_NOHUGEPAGE patch from this series. I'll submit a separate one that also changes riscv and x86 for consistency.

- Added a gcs_page_prot variable to store the protection for the gcs page, somewhat closer to what we do with protection_map[]. There are other ways to implement this, e.g. using PTE_MAYBE_SHARED or starting from protection_map[] and replacing the PIE bits with those from _PAGE_GCS_RO.

- The PROT_NONE patch was updated to drop the NUMA migration reference (this path is not exercised in that case), mention mprotect() instead. In addition, it checks VM_ACCESS_FLAGS instead of VM_READ|VM_WRITE.

- Added kselftest for the GCS PROT_NONE case.

Thanks.

Catalin Marinas (3):
arm64: gcs: Do not set PTE_SHARED on GCS mappings if FEAT_LPA2 is
enabled
arm64: gcs: Honour mprotect(PROT_NONE) on shadow stack mappings
kselftest: arm64: Check access to GCS after mprotect(PROT_NONE)

 arch/arm64/include/asm/pgtable-prot.h         |  3 -
 arch/arm64/mm/mmap.c                          | 12 ++-
 .../signal/testcases/gcs_prot_none_fault.c    | 76 +++++++++++++++++++
 3 files changed, 86 insertions(+), 5 deletions(-)
 create mode 100644 tools/testing/selftests/arm64/signal/testcases/gcs_prot_none_fault.c