linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nios2: fixed broken sys_clone syscall
@ 2021-02-05  8:23 Andreas Oetken
  2021-02-05  8:38 ` Christian Brauner
  0 siblings, 1 reply; 2+ messages in thread
From: Andreas Oetken @ 2021-02-05  8:23 UTC (permalink / raw)
  To: Ley Foon Tan, Christian Brauner, linux-kernel
  Cc: Andreas Oetken, Andreas Oetken

From: Andreas Oetken <andreas.oetken@siemens.com>

The tls pointer must be pushed on the stack prior to calling nios2_clone
as it is the 5th function argument. Prior handling of the tls pointer was
done inside former called function copy_thread_tls using the r8 register
from the current_pt_regs directly. This was a bad design and resulted in
the current bug introduced in 04bd52fb.

Fixes: 04bd52fb ("nios2: enable HAVE_COPY_THREAD_TLS, switch to kernel_clone_args")
Signed-off-by: Andreas Oetken <andreas.oetken@siemens.com>
---
 arch/nios2/kernel/entry.S | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/nios2/kernel/entry.S b/arch/nios2/kernel/entry.S
index da8442450e46..0794cd7803df 100644
--- a/arch/nios2/kernel/entry.S
+++ b/arch/nios2/kernel/entry.S
@@ -389,7 +389,10 @@ ENTRY(ret_from_interrupt)
  */
 ENTRY(sys_clone)
 	SAVE_SWITCH_STACK
+	subi    sp, sp, 4 /* make space for tls pointer */
+	stw     r8, 0(sp) /* pass tls pointer (r8) via stack (5th argument) */
 	call	nios2_clone
+	addi    sp, sp, 4
 	RESTORE_SWITCH_STACK
 	ret
 
-- 
2.30.0


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

* Re: [PATCH] nios2: fixed broken sys_clone syscall
  2021-02-05  8:23 [PATCH] nios2: fixed broken sys_clone syscall Andreas Oetken
@ 2021-02-05  8:38 ` Christian Brauner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Brauner @ 2021-02-05  8:38 UTC (permalink / raw)
  To: Andreas Oetken; +Cc: Ley Foon Tan, linux-kernel, Andreas Oetken, Andreas Oetken

On Fri, Feb 05, 2021 at 09:23:38AM +0100, Andreas Oetken wrote:
> From: Andreas Oetken <andreas.oetken@siemens.com>
> 
> The tls pointer must be pushed on the stack prior to calling nios2_clone
> as it is the 5th function argument. Prior handling of the tls pointer was
> done inside former called function copy_thread_tls using the r8 register
> from the current_pt_regs directly. This was a bad design and resulted in
> the current bug introduced in 04bd52fb.
> 
> Fixes: 04bd52fb ("nios2: enable HAVE_COPY_THREAD_TLS, switch to kernel_clone_args")
> Signed-off-by: Andreas Oetken <andreas.oetken@siemens.com>
> ---

Thanks for catching this!
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>

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

end of thread, other threads:[~2021-02-05  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-05  8:23 [PATCH] nios2: fixed broken sys_clone syscall Andreas Oetken
2021-02-05  8:38 ` Christian Brauner

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).