[RFC,v7,3/6] x86/entry: Erase kernel stack in syscall_trace_enter()
diff mbox

Message ID 1515766769-9120-4-git-send-email-alex.popov@linux.com
State New
Headers show

Commit Message

Alexander Popov Jan. 12, 2018, 2:19 p.m. UTC
Make STACKLEAK erase kernel stack after ptrace/seccomp/auditing
not to leave any sensitive information on the stack for the syscall code.

This code is modified from Brad Spengler/PaX Team's code in the last
public patch of grsecurity/PaX based on our understanding of the code.
Changes or omissions from the original code are ours and don't reflect
the original grsecurity/PaX code.

Signed-off-by: Alexander Popov <alex.popov@linux.com>
 arch/x86/entry/common.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff mbox

diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index d7d3cc2..cd38727 100644
--- a/arch/x86/entry/common.c
+++ b/arch/x86/entry/common.c
@@ -45,6 +45,12 @@  __visible inline void enter_from_user_mode(void)
 static inline void enter_from_user_mode(void) {}
+asmlinkage void erase_kstack(void);
+static void erase_kstack(void) {}
 static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch)
 #ifdef CONFIG_X86_64
@@ -127,6 +133,7 @@  static long syscall_trace_enter(struct pt_regs *regs)
 	do_audit_syscall_entry(regs, arch);
+	erase_kstack();
 	return ret ?: regs->orig_ax;