Re: [PATCH RFC 2/8] arm64: stacktrace: Add arch_within_stack_frames

2022-04-21 Thread He Zhe
On 4/19/22 22:40, Mark Rutland wrote: > Hi, > > On Mon, Apr 18, 2022 at 09:22:11PM +0800, He Zhe wrote: >> This function checks if the given address range crosses frame boundary. > I don't think that's quite true, becuase arm64's procedure call standard &

Re: [PATCH RFC 1/8] stacktrace: Change callback prototype to pass more information

2022-04-19 Thread He Zhe
On 4/19/22 21:09, Mark Rutland wrote: > On Mon, Apr 18, 2022 at 09:22:10PM +0800, He Zhe wrote: >> Currently stack_trace_consume_fn can only have pc of each frame of the >> stack. Copying-beyond-the-frame-detection also needs fp of current and >> previous frame. Other detec

Re: [PATCH RFC 2/8] arm64: stacktrace: Add arch_within_stack_frames

2022-04-19 Thread He Zhe
On 4/19/22 05:59, Kees Cook wrote: > On Mon, Apr 18, 2022 at 09:22:11PM +0800, He Zhe wrote: >> This function checks if the given address range crosses frame boundary. >> It is based on the existing x86 algorithm, but implemented via stacktrace. >>

[PATCH RFC 1/8] stacktrace: Change callback prototype to pass more information

2022-04-18 Thread He Zhe
: He Zhe --- include/linux/stacktrace.h | 9 - kernel/stacktrace.c| 10 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/stacktrace.h b/include/linux/stacktrace.h index 97455880ac41..5a61bfafe6f0 100644 --- a/include/linux/stacktrace.h +++ b

[PATCH RFC 6/8] s390: stacktrace: Make callbacks use new prototype with frame info

2022-04-18 Thread He Zhe
stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/s390/kernel

[PATCH RFC 3/8] arm64: stacktrace: Make callbacks use new prototype with frame info

2022-04-18 Thread He Zhe
stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/arm64/kernel

[PATCH RFC 2/8] arm64: stacktrace: Add arch_within_stack_frames

2022-04-18 Thread He Zhe
This function checks if the given address range crosses frame boundary. It is based on the existing x86 algorithm, but implemented via stacktrace. This can be tested by USERCOPY_STACK_FRAME_FROM and USERCOPY_STACK_FRAME_TO in lkdtm. Signed-off-by: He Zhe --- arch/arm64/Kconfig

[PATCH RFC 8/8] lkdtm: usercopy: Make USERCOPY_STACK_FRAME_x able to work for all archs

2022-04-18 Thread He Zhe
t's tune the test case to validate current one. We can simply use __builtin_frame_address(0) as a bad start address that can be detected for all architectures. Signed-off-by: He Zhe --- drivers/misc/lkdtm/usercopy.c | 24 +--- 1 file changed, 1 insertion(+), 23 deletions(

[PATCH RFC 7/8] x86: stacktrace: Make callbacks use new prototype with frame info

2022-04-18 Thread He Zhe
stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/x86/kernel

[PATCH RFC 5/8] riscv: stacktrace: Make callbacks use new prototype with frame info

2022-04-18 Thread He Zhe
stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/riscv/include/asm

[PATCH RFC 0/8] hardened usercopy and stacktrace improvement

2022-04-18 Thread He Zhe
tack frame case. Currently the way to generate bad frame use depends on stack layout of the architecture and compiler. It happens to work with x86 but does not work for arm64 and it ruins the stack in USERCOPY_STACK_FRAME_FROM and thus causes the call chain to return to NULL address.

[PATCH RFC 4/8] powerpc: stacktrace: Make callbacks use new prototype with frame info

2022-04-18 Thread He Zhe
stack_trace_consume_fn has been changed to bool (*stack_trace_consume_fn)(void *cookie, struct frame_info *fi); to be able to pass more information. Turn to use pc in struct frame_info in arch_stack_walk callbacks without functinoal change. Signed-off-by: He Zhe --- arch/powerpc/kernel