Skip to contentSkip to conversation

m68k: syscall: fix syscall_get_arguments() argument mapping

PATCH In review Yiqi Sun 2 participants 2 messages May 29 m68k architecture

lore
Share & tools
lore

Yiqi Sun

author
#0 lore raw

PATCH 1/1 m68k: syscall: fix syscall_get_arguments() argument mapping

On m68k, syscall_get_arguments() currently returns orig_d0 as args[0], followed by d1-d5 as args[1..5].

However, syscall arguments are passed in d1-d5 and a0, so args[0] should reflect d1, and the full argument set should include a0.

Fix the mapping by copying all six arguments from the saved register block starting at d1.

Fixes 6baaade15594 ("m68k: Add kernel seccomp support")
---
 arch/m68k/include/asm/syscall.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
arch/m68k/include/asm/syscall.h +1 -4
index bf84b160c2eb..2e268eeedad3 100644
@@ -52,10 +52,7 @@ static inline void syscall_get_arguments(struct task_struct *task,
 					 struct pt_regs *regs,
 					 unsigned long *args)
 {
-	args[0] = regs->orig_d0;
-	args++;
-
-	memcpy(args, &regs->d1, 5 * sizeof(args[0]));
+	memcpy(args, &regs->d1, 6 * sizeof(args[0]));
 }
 
 static inline void syscall_set_arguments(struct task_struct *task,
Signature · 1 line
2.34.1
#1 lore raw

Yiqi,

thanks for your patch!

Quoted 2 lines · Yiqi Sun

On m68k, syscall_get_arguments() currently returns orig_d0 as args[0], followed by d1-d5 as args[1..5].

From my reading of other arch's syscall.h code at the time the patch was written, the syscall nr passed in d0 appeared to be considered the first argument to be returned. It now appears that that was incorrect - I don't suppose the semantics of this function changed over the past three years?

m68k seccomp support was rather incomplete back then, and I've seen more contributions recently. Does this cause any regressions or improvements to the seccomp_bpf tests or other test results?

Quoted 19 lines

However, syscall arguments are passed in d1-d5 and a0, so args[0] should reflect d1, and the full argument set should include a0.

Fix the mapping by copying all six arguments from the saved register block starting at d1.

Fixes 6baaade15594 ("m68k: Add kernel seccomp support")
---
  arch/m68k/include/asm/syscall.h | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
arch/m68k/include/asm/syscall.h +0 -0
index bf84b160c2eb..2e268eeedad3 100644
@@ -52,10 +52,7 @@ static inline void syscall_get_arguments(struct task_struct *task,
  					 struct pt_regs *regs,

arch/m68k/include/asm/syscall.h static inline void syscall_get_arguments(struct task_struct *task, · line 58

Quoted 10 lines
arch/m68k/include/asm/syscall.h +1 -4
  					 unsigned long *args)
  {
-	args[0] = regs->orig_d0;
-	args++;
-
-	memcpy(args, &regs->d1, 5 * sizeof(args[0]));
+	memcpy(args, &regs->d1, 6 * sizeof(args[0]));
  }
 
  static inline void syscall_set_arguments(struct task_struct *task,

Any reason for not applying the same change to syscall_set_arguments() here?

Cheers,

    Michael