Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390: enable HAVE_ARCH_STACKLEAK

Add support for the stackleak feature. Whenever the kernel returns to user
space the kernel stack is filled with a poison value.

Enabling this feature is quite expensive: e.g. after instrumenting the
getpid() system call function to have a 4kb stack the result is an
increased runtime of the system call by a factor of 3.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Heiko Carstens and committed by
Vasily Gorbik
b94c0ebb 22ca1e77

+11
+1
arch/s390/Kconfig
··· 155 155 select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET 156 156 select HAVE_ARCH_SECCOMP_FILTER 157 157 select HAVE_ARCH_SOFT_DIRTY 158 + select HAVE_ARCH_STACKLEAK 158 159 select HAVE_ARCH_TRACEHOOK 159 160 select HAVE_ARCH_TRANSPARENT_HUGEPAGE 160 161 select HAVE_ARCH_VMAP_STACK
+10
arch/s390/kernel/entry.S
··· 150 150 .endm 151 151 #endif 152 152 153 + .macro STACKLEAK_ERASE 154 + #ifdef CONFIG_GCC_PLUGIN_STACKLEAK 155 + brasl %r14,stackleak_erase_on_task_stack 156 + #endif 157 + .endm 158 + 153 159 GEN_BR_THUNK %r14 154 160 155 161 .section .kprobes.text, "ax" ··· 306 300 MBEAR %r2 307 301 lgr %r3,%r14 308 302 brasl %r14,__do_syscall 303 + STACKLEAK_ERASE 309 304 lctlg %c1,%c1,__LC_USER_ASCE 310 305 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15) 311 306 BPON ··· 322 315 ENTRY(ret_from_fork) 323 316 lgr %r3,%r11 324 317 brasl %r14,__ret_from_fork 318 + STACKLEAK_ERASE 325 319 lctlg %c1,%c1,__LC_USER_ASCE 326 320 mvc __LC_RETURN_PSW(16),STACK_FRAME_OVERHEAD+__PT_PSW(%r15) 327 321 BPON ··· 383 375 brasl %r14,__do_pgm_check 384 376 tmhh %r8,0x0001 # returning to user space? 385 377 jno .Lpgm_exit_kernel 378 + STACKLEAK_ERASE 386 379 lctlg %c1,%c1,__LC_USER_ASCE 387 380 BPON 388 381 stpt __LC_EXIT_TIMER ··· 449 440 mvc __LC_RETURN_PSW(16),__PT_PSW(%r11) 450 441 tmhh %r8,0x0001 # returning to user ? 451 442 jno 2f 443 + STACKLEAK_ERASE 452 444 lctlg %c1,%c1,__LC_USER_ASCE 453 445 BPON 454 446 stpt __LC_EXIT_TIMER