[PATCH RFC/RFT 0/3] Converge common flows for cpu assisted shadow stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



x86, arm64 and risc-v support cpu assisted shadow stack. x86 was first
one and most of the shadow stack related code is in x86 arch directory.
arm64 guarded control stack (GCS) patches from Mark Brown are in -next.

There are significant flows which are quite common between all 3 arches:

- Enabling is via prctl.
- Managing virtual memory for shadow stack handled similarly.
- Virtual memory management of shadow stack on clone/fork is similar.

This led to obvious discussion many how to merge certain common flows in
generic code. Recent one being [1]. Goes without saying having generic
code helps with bug management as well (not having to fix same bug for 3
different arches).

In that attempt, Mark brown introduced `ARCH_HAS_SHADOW_STACK` as part
of arm64 gcs series [2]. This patchset uses same config to move as much
as possible common code in generic kernel. Additionaly this patchset
introduces wrapper abstractions where arch specific handling is required.
I looked at only x86 and risc-v while carving out common code and defining
these abstractions. Mark, please take a look at this and point out if arm64
would require something additional (or removal).

I've not tested this. Only compiled for x86 with shadow stack enable. Thus
this is a RFC and possible looking for some help to test as well on x86.

[1] - https://lore.kernel.org/all/20241008-v5_user_cfi_series-v6-0-60d9fe073f37@xxxxxxxxxxxx/T/#m98d14237663150778a3f8df59a76a3fe6318624a

[2] - https://lore.kernel.org/linux-arm-kernel/20241001-arm64-gcs-v13-0-222b78d87eee@xxxxxxxxxx/T/#m1ff65a49873b0e770e71de7af178f581c72be7ad

To: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
To: Ingo Molnar <mingo@xxxxxxxxxx>
To: Borislav Petkov <bp@xxxxxxxxx>
To: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
To: x86@xxxxxxxxxx
To: H. Peter Anvin <hpa@xxxxxxxxx>
To: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
To: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
To: Vlastimil Babka <vbabka@xxxxxxx>
To: Lorenzo Stoakes <lorenzo.stoakes@xxxxxxxxxx>
To: Arnd Bergmann <arnd@xxxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
Cc: linux-fsdevel@xxxxxxxxxxxxxxx
Cc: linux-mm@xxxxxxxxx
Cc: linux-arch@xxxxxxxxxxxxxxx
Cc: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
Cc: Mark Brown <broonie@xxxxxxxxxx>

Signed-off-by: Deepak Gupta <debug@xxxxxxxxxxxx>
---
Deepak Gupta (2):
      mm: helper `is_shadow_stack_vma` to check shadow stack vma
      kernel: converge common shadow stack flow agnostic to arch

Mark Brown (1):
      mm: Introduce ARCH_HAS_USER_SHADOW_STACK

 arch/x86/Kconfig                       |   1 +
 arch/x86/include/asm/shstk.h           |   9 +
 arch/x86/include/uapi/asm/mman.h       |   3 -
 arch/x86/kernel/shstk.c                | 270 ++++++------------------------
 fs/proc/task_mmu.c                     |   2 +-
 include/linux/mm.h                     |   2 +-
 include/linux/usershstk.h              |  25 +++
 include/uapi/asm-generic/mman-common.h |   3 +
 kernel/Makefile                        |   2 +
 kernel/usershstk.c                     | 289 +++++++++++++++++++++++++++++++++
 mm/Kconfig                             |   6 +
 mm/gup.c                               |   2 +-
 mm/vma.h                               |  10 +-
 13 files changed, 392 insertions(+), 232 deletions(-)
---
base-commit: 9852d85ec9d492ebef56dc5f229416c925758edc
change-id: 20241010-shstk_converge-aefbcbef5d71
--
- debug





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux