From mboxrd@z Thu Jan 1 00:00:00 1970 References: <1512516827-29797-1-git-send-email-alex.popov@linux.com> <1512516827-29797-6-git-send-email-alex.popov@linux.com> From: Alexander Popov Message-ID: <5fb044ec-cf1e-6281-01a9-c845b738914e@linux.com> Date: Thu, 7 Dec 2017 10:09:27 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: [kernel-hardening] Re: [PATCH RFC v6 5/6] fs/proc: Show STACKLEAK metrics in the /proc file system To: Laura Abbott , kernel-hardening@lists.openwall.com, Kees Cook , PaX Team , Brad Spengler , Ingo Molnar , Andy Lutomirski , Tycho Andersen , Mark Rutland , Ard Biesheuvel , Borislav Petkov , Thomas Gleixner , "H . Peter Anvin" , Peter Zijlstra , x86@kernel.org, "Tobin C. Harding" List-ID: Hello Laura and Kees, [adding Tobin C. Harding] On 06.12.2017 22:22, Laura Abbott wrote: > On 12/05/2017 03:33 PM, Alexander Popov wrote: >> Introduce CONFIG_STACKLEAK_METRICS providing STACKLEAK information about >> tasks via the /proc file system. In particular, /proc//lowest_stack >> shows the current lowest_stack value and its final value from the previous >> syscall. That information can be useful for estimating the STACKLEAK >> performance impact for different workloads. >> >> Signed-off-by: Alexander Popov >> --- >> arch/Kconfig | 11 +++++++++++ >> arch/x86/entry/entry_32.S | 4 ++++ >> arch/x86/entry/entry_64.S | 4 ++++ >> arch/x86/include/asm/processor.h | 3 +++ >> arch/x86/kernel/asm-offsets.c | 3 +++ >> arch/x86/kernel/process_32.c | 3 +++ >> arch/x86/kernel/process_64.c | 3 +++ >> fs/proc/base.c | 14 ++++++++++++++ >> 8 files changed, 45 insertions(+) [...] >> +#ifdef CONFIG_STACKLEAK_METRICS >> +static int proc_lowest_stack(struct seq_file *m, struct pid_namespace *ns, >> + struct pid *pid, struct task_struct *task) >> +{ >> + seq_printf(m, "prev_lowest_stack: %pK\nlowest_stack: %pK\n", >> + (void *)task->thread.prev_lowest_stack, >> + (void *)task->thread.lowest_stack); >> + return 0; >> +} >> +#endif /* CONFIG_STACKLEAK_METRICS */ >> + > > This just prints the hashed value with the new pointer leak work. > I don't think we want to print the fully exposed value via %px so > it's not clear how valuable this proc file is now. Yes, I tested that before sending the patch. I was confused when I saw the hashed values. But setting kptr_restrict to 1 fixed that for me: root@hobbit:~# cat /proc/2627/lowest_stack prev_lowest_stack: 00000000ed8ca991 lowest_stack: 0000000040579d76 root@hobbit:~# echo 1 > /proc/sys/kernel/kptr_restrict root@hobbit:~# cat /proc/2627/lowest_stack prev_lowest_stack: ffffc9000094fdb8 lowest_stack: ffffc9000094f9e0 However, Documentation/printk-formats.txt and Documentation/sysctl/kernel.txt don't specify that behaviour. Best regards, Alexander