linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase()
@ 2018-11-12 21:08 Alexander Popov
  2018-11-13  1:49 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexander Popov @ 2018-11-12 21:08 UTC (permalink / raw)
  To: kernel-hardening, Kees Cook, Jann Horn, Ingo Molnar,
	Andy Lutomirski, Joerg Roedel, Borislav Petkov, Thomas Gleixner,
	Dave Hansen, Steven Rostedt, Peter Zijlstra, Jan Kara,
	Mathieu Desnoyers, Dan Williams, Masahiro Yamada,
	Masami Hiramatsu, x86, alex.popov, linux-kernel

The stackleak_erase() function is called on the trampoline stack at the end
of syscall. This stack is not big enough for ftrace and kprobes operations,
e.g. it can be exhausted if we use kprobe_events for stackleak_erase().

So let's disable function tracing and kprobes for stackleak_erase().

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Alexander Popov <alex.popov@linux.com>
---
 kernel/stackleak.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/stackleak.c b/kernel/stackleak.c
index e428929..08cb57e 100644
--- a/kernel/stackleak.c
+++ b/kernel/stackleak.c
@@ -11,6 +11,7 @@
  */
 
 #include <linux/stackleak.h>
+#include <linux/kprobes.h>
 
 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
 #include <linux/jump_label.h>
@@ -47,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write,
 #define skip_erasing()	false
 #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */
 
-asmlinkage void stackleak_erase(void)
+asmlinkage void notrace stackleak_erase(void)
 {
 	/* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */
 	unsigned long kstack_ptr = current->lowest_stack;
@@ -101,6 +102,7 @@ asmlinkage void stackleak_erase(void)
 	/* Reset the 'lowest_stack' value for the next syscall */
 	current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64;
 }
+NOKPROBE_SYMBOL(stackleak_erase);
 
 void __used stackleak_track_stack(void)
 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase()
  2018-11-12 21:08 [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase() Alexander Popov
@ 2018-11-13  1:49 ` Steven Rostedt
  2018-11-13 18:23 ` Masami Hiramatsu
  2018-11-13 20:06 ` Kees Cook
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2018-11-13  1:49 UTC (permalink / raw)
  To: Alexander Popov
  Cc: kernel-hardening, Kees Cook, Jann Horn, Ingo Molnar,
	Andy Lutomirski, Joerg Roedel, Borislav Petkov, Thomas Gleixner,
	Dave Hansen, Peter Zijlstra, Jan Kara, Mathieu Desnoyers,
	Dan Williams, Masahiro Yamada, Masami Hiramatsu, x86,
	linux-kernel

On Tue, 13 Nov 2018 00:08:48 +0300
Alexander Popov <alex.popov@linux.com> wrote:

> The stackleak_erase() function is called on the trampoline stack at the end
> of syscall. This stack is not big enough for ftrace and kprobes operations,
> e.g. it can be exhausted if we use kprobe_events for stackleak_erase().
> 
> So let's disable function tracing and kprobes for stackleak_erase().
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Alexander Popov <alex.popov@linux.com>
>

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>

-- Steve

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase()
  2018-11-12 21:08 [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase() Alexander Popov
  2018-11-13  1:49 ` Steven Rostedt
@ 2018-11-13 18:23 ` Masami Hiramatsu
  2018-11-13 20:06 ` Kees Cook
  2 siblings, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2018-11-13 18:23 UTC (permalink / raw)
  To: Alexander Popov
  Cc: kernel-hardening, Kees Cook, Jann Horn, Ingo Molnar,
	Andy Lutomirski, Joerg Roedel, Borislav Petkov, Thomas Gleixner,
	Dave Hansen, Steven Rostedt, Peter Zijlstra, Jan Kara,
	Mathieu Desnoyers, Dan Williams, Masahiro Yamada, x86,
	linux-kernel

On Tue, 13 Nov 2018 00:08:48 +0300
Alexander Popov <alex.popov@linux.com> wrote:

> The stackleak_erase() function is called on the trampoline stack at the end
> of syscall. This stack is not big enough for ftrace and kprobes operations,
> e.g. it can be exhausted if we use kprobe_events for stackleak_erase().
> 
> So let's disable function tracing and kprobes for stackleak_erase().
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Alexander Popov <alex.popov@linux.com>

Reviewed-by: Masami Hiramatsu <mhiramat@kernel.org>

Thank you!

> ---
>  kernel/stackleak.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/stackleak.c b/kernel/stackleak.c
> index e428929..08cb57e 100644
> --- a/kernel/stackleak.c
> +++ b/kernel/stackleak.c
> @@ -11,6 +11,7 @@
>   */
>  
>  #include <linux/stackleak.h>
> +#include <linux/kprobes.h>
>  
>  #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
>  #include <linux/jump_label.h>
> @@ -47,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write,
>  #define skip_erasing()	false
>  #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */
>  
> -asmlinkage void stackleak_erase(void)
> +asmlinkage void notrace stackleak_erase(void)
>  {
>  	/* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */
>  	unsigned long kstack_ptr = current->lowest_stack;
> @@ -101,6 +102,7 @@ asmlinkage void stackleak_erase(void)
>  	/* Reset the 'lowest_stack' value for the next syscall */
>  	current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64;
>  }
> +NOKPROBE_SYMBOL(stackleak_erase);
>  
>  void __used stackleak_track_stack(void)
>  {
> -- 
> 2.7.4
> 


-- 
Masami Hiramatsu <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase()
  2018-11-12 21:08 [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase() Alexander Popov
  2018-11-13  1:49 ` Steven Rostedt
  2018-11-13 18:23 ` Masami Hiramatsu
@ 2018-11-13 20:06 ` Kees Cook
  2 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2018-11-13 20:06 UTC (permalink / raw)
  To: Alexander Popov
  Cc: Kernel Hardening, Jann Horn, Ingo Molnar, Andy Lutomirski,
	Joerg Roedel, Borislav Petkov, Thomas Gleixner, Dave Hansen,
	Steven Rostedt, Peter Zijlstra, Jan Kara, Mathieu Desnoyers,
	Dan Williams, Masahiro Yamada, Masami Hiramatsu, X86 ML, LKML

On Mon, Nov 12, 2018 at 3:08 PM, Alexander Popov <alex.popov@linux.com> wrote:
> The stackleak_erase() function is called on the trampoline stack at the end
> of syscall. This stack is not big enough for ftrace and kprobes operations,
> e.g. it can be exhausted if we use kprobe_events for stackleak_erase().
>
> So let's disable function tracing and kprobes for stackleak_erase().
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Alexander Popov <alex.popov@linux.com>

Thanks! I'll get this into my tree.

-Kees

> ---
>  kernel/stackleak.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/stackleak.c b/kernel/stackleak.c
> index e428929..08cb57e 100644
> --- a/kernel/stackleak.c
> +++ b/kernel/stackleak.c
> @@ -11,6 +11,7 @@
>   */
>
>  #include <linux/stackleak.h>
> +#include <linux/kprobes.h>
>
>  #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
>  #include <linux/jump_label.h>
> @@ -47,7 +48,7 @@ int stack_erasing_sysctl(struct ctl_table *table, int write,
>  #define skip_erasing() false
>  #endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */
>
> -asmlinkage void stackleak_erase(void)
> +asmlinkage void notrace stackleak_erase(void)
>  {
>         /* It would be nice not to have 'kstack_ptr' and 'boundary' on stack */
>         unsigned long kstack_ptr = current->lowest_stack;
> @@ -101,6 +102,7 @@ asmlinkage void stackleak_erase(void)
>         /* Reset the 'lowest_stack' value for the next syscall */
>         current->lowest_stack = current_top_of_stack() - THREAD_SIZE/64;
>  }
> +NOKPROBE_SYMBOL(stackleak_erase);
>
>  void __used stackleak_track_stack(void)
>  {
> --
> 2.7.4
>



-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-11-13 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 21:08 [PATCH 1/1] stackleak: Disable function tracing and kprobes for stackleak_erase() Alexander Popov
2018-11-13  1:49 ` Steven Rostedt
2018-11-13 18:23 ` Masami Hiramatsu
2018-11-13 20:06 ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).