Skip to content

RFC Allow tasks to have their user stack pointer sanity checked

Will Deacon lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4mm: Check user stack pointer is mapped with MAP_STACKinclude/linux/mm.h include/linux/mman.h include/linux/sched.h +1 more+60 -20 replies
2/4mm: Expose user stack pointer checking via prctl()include/linux/mm.h include/uapi/linux/prctl.h kernel/sys.c +1 more+37 -00 replies
3/4mm: Add kconfig entries for user stack pointer checkingmm/Kconfig+17 -00 replies
4/4arm64: Check user stack pointer on syscall entryarch/arm64/Kconfig arch/arm64/kernel/syscall.c+5 -00 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchKees Cook
SeriesR-b
1/4
2/4
3/4
4/4

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

Read the v1 thread

Cover letter [RFC PATCH 0/4] Allow tasks to have their user stack pointer sanity checked

Hi all,

I attended an interesting talk at LCA last month that described some of the security features deployed in OpenBSD [1]. One hardening feature that piqued my interest was, on syscall entry and page faults from userspace, checking that the user stack pointer for a task points at pages that were either allocated by the kernel for the initial process stack of mapped with mmap() using the MAP_STACK flag. This acts as a basic defense against stack pivoting attacks.

The problem with this checking is that it is a retrospective tightening of the ABI, but that hasn't stopped me hacking it together behind a couple of prctl() options.

Anyway, it was fun to implement so I figured I'd post it as an RFC.

Will

[1] https://2019.linux.conf.au/schedule/presentation/164/

Cc Kees Cook <[email protected]>
Cc Jann Horn <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Peter Zijlstra <[email protected]>

--->8

Will Deacon (4):
mm: Check user stack pointer is mapped with MAP_STACK
mm: Expose user stack pointer checking via prctl()
mm: Add kconfig entries for user stack pointer checking
arm64: Check user stack pointer on syscall entry

 arch/arm64/Kconfig          |  1 +
 arch/arm64/kernel/syscall.c |  4 +++
 include/linux/mm.h          | 15 +++++++++-
 include/linux/mman.h        |  3 +-
 include/linux/sched.h       |  4 +++
 include/uapi/linux/prctl.h  |  5 ++++
 kernel/sys.c                |  5 ++++
 mm/Kconfig                  | 17 ++++++++++++
 mm/memory.c                 | 67 +++++++++++++++++++++++++++++++++++++++++++++
 9 files changed, 119 insertions(+), 2 deletions(-)
Signature · 1 line
2.11.0