Skip to contentSkip to conversation

s390: ensure that syscall arguments are properly masked on s390

PATCH In review Paul Moore 2 participants 3 messages Jun 27, 2016 – Jun 28, 2016

Subsystems (2)
lore
Share & tools
lore

Paul Moore

author
#0 lore raw

PATCH v2 1/1 s390: ensure that syscall arguments are properly masked on s390

From: Paul Moore <[email protected]>

When executing s390 code on s390x the syscall arguments are not properly masked, leading to some malformed audit records.

---
 arch/s390/kernel/ptrace.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
arch/s390/kernel/ptrace.c +7 -3
index 49b1c13..defc0dc 100644
@@ -822,6 +822,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 {
 	long ret = 0;
+	unsigned long mask = -1UL;
 
 	/* Do the secure computing check first. */
 	if (secure_computing()) {
@@ -849,9 +850,12 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 	if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
 		trace_sys_enter(regs, regs->gprs[2]);
 
-	audit_syscall_entry(regs->gprs[2], regs->orig_gpr2,
-			    regs->gprs[3], regs->gprs[4],
-			    regs->gprs[5]);
+	if (is_compat_task())
+		mask = 0xffffffff;
+
+	audit_syscall_entry(regs->gprs[2], regs->orig_gpr2 & mask,
+			    regs->gprs[3] & mask, regs->gprs[4] & mask,
+			    regs->gprs[5] & mask);
 out:
 	return ret ?: regs->gprs[2];
 }
author
#1 lore raw
Quoted 9 lines · Paul Moore

From: Paul Moore <[email protected]>

When executing s390 code on s390x the syscall arguments are not properly masked, leading to some malformed audit records.

---
 arch/s390/kernel/ptrace.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

The only change between v2 and the original patch is the use of is_compat_task() instead of the #ifdef, as suggested by Heiko. Like before, I've added this patch to the audit#next branch; I think we have sorted all the feedback, but if any objections remain please let me know.

Quoted 29 lines
arch/s390/kernel/ptrace.c +7 -3
index 49b1c13..defc0dc 100644
@@ -822,6 +822,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
 {
        long ret = 0;
+       unsigned long mask = -1UL;
 
        /* Do the secure computing check first. */
        if (secure_computing()) {
@@ -849,9 +850,12 @@ asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
        if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
                trace_sys_enter(regs, regs->gprs[2]);
 
-       audit_syscall_entry(regs->gprs[2], regs->orig_gpr2,
-                           regs->gprs[3], regs->gprs[4],
-                           regs->gprs[5]);
+       if (is_compat_task())
+               mask = 0xffffffff;
+
+       audit_syscall_entry(regs->gprs[2], regs->orig_gpr2 & mask,
+                           regs->gprs[3] & mask, regs->gprs[4] & mask,
+                           regs->gprs[5] & mask);
 out:
        return ret ?: regs->gprs[2];
 }
Signature · 2 lines
paul moore
security @ redhat
#2 lore raw
Quoted 11 lines · Paul Moore
Quoted 9 lines · Paul Moore

From: Paul Moore <[email protected]>

When executing s390 code on s390x the syscall arguments are not properly masked, leading to some malformed audit records.

---
 arch/s390/kernel/ptrace.c |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
Quoted 5 lines

The only change between v2 and the original patch is the use of is_compat_task() instead of the #ifdef, as suggested by Heiko. Like before, I've added this patch to the audit#next branch; I think we have sorted all the feedback, but if any objections remain please let me know.

Thanks!