Skip to content

arm64: usercopy: Implement stack frame object validation

James Morse kernel-hardening linux-arm-kernel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest3 patches 9 repliesIn review

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3usercopy: create enum stack_typearch/x86/include/asm/thread_info.h include/linux/thread_info.h mm/usercopy.c+21 -191 reply
2/3arm64: Add arch_within_stack_frames() for hardened usercopyarch/arm64/Kconfig arch/arm64/include/asm/thread_info.h arch/arm64/kernel/stacktrace.c+58 -41 reply
3/3arm64/uaccess: Add hardened usercopy check for bad stack accessesarch/arm64/include/asm/uaccess.h+20 -03 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchKees Cook
1/3R-b A-b
2/3
3/3

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

Read the v4 thread

Cover letter [kernel-hardening] [PATCH v4 0/3] arm64: usercopy: Implement stack frame object validation

Hi all,

This version of Sahara's arch_within_stack_frames() series replaces the open-coded stack walker with a call to arm64's existing walker.

Patch 2 can be tested independently with this change[0].

lkdtm's use of unallocated stack regions is a separate problem, patch 3 tries to address this.

Sahara, it would be good to get your review of this!
I'm afraid I omitted your patch-3 as it stopped the lkdtm test from working, I suspect its not tricking the compiler, but I haven't investigated.

Thanks,

James

[0] Change to lkdtm to generate accesses that overlap stack frames. --------------%<--------------

drivers/misc/lkdtm_usercopy.c +2 -1
index 1dd611423d8b..fcbba3a14387 100644
@@ -57,7 +57,8 @@ static noinline void do_usercopy_stack(bool to_user, bool bad_frame)
 
        /* This is a pointer to outside our current stack frame. */
        if (bad_frame) {
-               bad_stack = do_usercopy_stack_callee((uintptr_t)&bad_stack);
+               bad_stack = __builtin_frame_address(0);
+               bad_stack -= sizeof(good_stack)/2;
        } else {
                /* Put start address just inside stack. */
                bad_stack = task_stack_page(current) + THREAD_SIZE;

--------------%<--------------

James Morse (2):
arm64: Add arch_within_stack_frames() for hardened usercopy arm64/uaccess: Add hardened usercopy check for bad stack accesses

Sahara (1):
usercopy: create enum stack_type

 arch/arm64/Kconfig                   |  1 +
 arch/arm64/include/asm/thread_info.h |  7 ++++-
 arch/arm64/include/asm/uaccess.h     | 20 +++++++++++++
 arch/arm64/kernel/stacktrace.c       | 54 ++++++++++++++++++++++++++++++++++--
 arch/x86/include/asm/thread_info.h   | 19 +++++++------
 include/linux/thread_info.h          | 13 +++++++--
 mm/usercopy.c                        |  8 +-----
 7 files changed, 99 insertions(+), 23 deletions(-)
Signature · 1 line
2.10.1