Skip to contentSkip to conversation

nios2: fixed broken sys_clone syscall

PATCH In review Andreas Oetken 2 participants 2 messages Feb 5, 2021 NIOS2 architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nios2: fixed broken sys_clone syscall

From: Andreas Oetken <[email protected]>

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")
---
 arch/nios2/kernel/entry.S | 3 +++
 1 file changed, 3 insertions(+)
arch/nios2/kernel/entry.S +3 -0
index da8442450e46..0794cd7803df 100644
@@ -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
 
Signature · 1 line
2.30.0
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Andreas Oetken

From: Andreas Oetken <[email protected]>

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

---

Thanks for catching this!