Skip to contentSkip to conversation

MIPS: Fix syscall_get_nr for the syscall exit tracing.

PATCH In review Lars Persson 2 participants 2 messages Feb 3, 2015 – Feb 12, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 MIPS: Fix syscall_get_nr for the syscall exit tracing.

Register 2 is alredy overwritten by the return value when syscall_trace_leave() is called.

---
 arch/mips/include/asm/syscall.h     |    8 +-------
 arch/mips/include/asm/thread_info.h |    1 +
 arch/mips/kernel/ptrace.c           |    2 ++
 3 files changed, 4 insertions(+), 7 deletions(-)
arch/mips/include/asm/syscall.h +1 -7
index bb79637..6499d93 100644
@@ -29,13 +29,7 @@
 static inline long syscall_get_nr(struct task_struct *task,
 				  struct pt_regs *regs)
 {
-	/* O32 ABI syscall() - Either 64-bit with O32 or 32-bit */
-	if ((config_enabled(CONFIG_32BIT) ||
-	    test_tsk_thread_flag(task, TIF_32BIT_REGS)) &&
-	    (regs->regs[2] == __NR_syscall))
-		return regs->regs[4];
-	else
-		return regs->regs[2];
+	return current_thread_info()->syscall;
 }
 
 static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
arch/mips/include/asm/thread_info.h +1 -0
index 99eea59..e4440f9 100644
@@ -36,6 +36,7 @@ struct thread_info {
 						 */
 	struct restart_block	restart_block;
 	struct pt_regs		*regs;
+	long			syscall;	/* syscall number */
 };
 
 /*
arch/mips/kernel/ptrace.c +2 -0
index 9d1487d..5104528 100644
@@ -770,6 +770,8 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
 	long ret = 0;
 	user_exit();
 
+	current_thread_info()->syscall = syscall;
+
 	if (secure_computing() == -1)
 		return -1;
 
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 47 lines · Lars Persson

Register 2 is alredy overwritten by the return value when syscall_trace_leave() is called.

---
 arch/mips/include/asm/syscall.h     |    8 +-------
 arch/mips/include/asm/thread_info.h |    1 +
 arch/mips/kernel/ptrace.c           |    2 ++
 3 files changed, 4 insertions(+), 7 deletions(-)
arch/mips/include/asm/syscall.h +1 -7
index bb79637..6499d93 100644
@@ -29,13 +29,7 @@
 static inline long syscall_get_nr(struct task_struct *task,
 				  struct pt_regs *regs)
 {
-	/* O32 ABI syscall() - Either 64-bit with O32 or 32-bit */
-	if ((config_enabled(CONFIG_32BIT) ||
-	    test_tsk_thread_flag(task, TIF_32BIT_REGS)) &&
-	    (regs->regs[2] == __NR_syscall))
-		return regs->regs[4];
-	else
-		return regs->regs[2];
+	return current_thread_info()->syscall;
 }
 
 static inline unsigned long mips_get_syscall_arg(unsigned long *arg,
arch/mips/include/asm/thread_info.h +1 -0
index 99eea59..e4440f9 100644
@@ -36,6 +36,7 @@ struct thread_info {
 						 */
 	struct restart_block	restart_block;
 	struct pt_regs		*regs;
+	long			syscall;	/* syscall number */
 };
 
 /*
arch/mips/kernel/ptrace.c +0 -0
index 9d1487d..5104528 100644

arch/mips/kernel/ptrace.c asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall) · line 777

Quoted 8 lines
arch/mips/kernel/ptrace.c +2 -0
@@ -770,6 +770,8 @@ asmlinkage long syscall_trace_enter(struct pt_regs *regs, long syscall)
 	long ret = 0;
 	user_exit();
 
+	current_thread_info()->syscall = syscall;
+
 	if (secure_computing() == -1)
 		return -1;
 

Hi,

This is now in mainline but parts of it can apply to stable as well? Would you be willing to send a backported version for the stable trees? Thanks a lot

Signature · 1 line
markos