lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201119221033.Horde.be-msjDTeIW4XeXARjUu7g1@messagerie.c-s.fr>
Date:   Thu, 19 Nov 2020 22:10:33 +0100
From:   Christophe Leroy <christophe.leroy@...roup.eu>
To:     Oleg Nesterov <oleg@...hat.com>
Cc:     Benjamin Herrenschmidt <benh@...nel.crashing.org>,
        Madhavan Srinivasan <maddy@...ux.vnet.ibm.com>,
        Michael Ellerman <mpe@...erman.id.au>,
        Paul Mackerras <paulus@...ba.org>,
        Al Viro <viro@...iv.linux.org.uk>,
        "Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>,
        Christophe Leroy <christophe.leroy@....fr>,
        Jan Kratochvil <jan.kratochvil@...hat.com>,
        Nicholas Piggin <npiggin@...il.com>,
        linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] powerpc/ptrace: Hard wire PT_SOFTE value to 1 in
 gpr_get() too


Quoting Oleg Nesterov <oleg@...hat.com>:

> The commit a8a4b03ab95f ("powerpc: Hard wire PT_SOFTE value to 1 in
> ptrace & signals") changed ptrace_get_reg(PT_SOFTE) to report 0x1,
> but PTRACE_GETREGS still copies pt_regs->softe as is.
>
> This is not consistent and this breaks the user-regs-peekpoke test
> from https://sourceware.org/systemtap/wiki/utrace/tests/
>
> Reported-by: Jan Kratochvil <jan.kratochvil@...hat.com>
> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
> ---
>  arch/powerpc/kernel/ptrace/ptrace-tm.c   | 8 +++++++-
>  arch/powerpc/kernel/ptrace/ptrace-view.c | 8 +++++++-
>  2 files changed, 14 insertions(+), 2 deletions(-)
>

I think the following should work, and not require the first patch  
(compile tested only).

diff --git a/arch/powerpc/kernel/ptrace/ptrace-tm.c  
b/arch/powerpc/kernel/ptrace/ptrace-tm.c
index 54f2d076206f..f779b3bc0279 100644
--- a/arch/powerpc/kernel/ptrace/ptrace-tm.c
+++ b/arch/powerpc/kernel/ptrace/ptrace-tm.c
@@ -104,8 +104,14 @@ int tm_cgpr_get(struct task_struct *target, const  
struct user_regset *regset,
  		     offsetof(struct pt_regs, msr) + sizeof(long));

  	membuf_write(&to, &target->thread.ckpt_regs.orig_gpr3,
-			sizeof(struct user_pt_regs) -
-			offsetof(struct pt_regs, orig_gpr3));
+		     offsetof(struct pt_regs, softe) - offsetof(struct pt_regs,  
orig_gpr3));
+	membuf_store(&to, 1UL);
+
+	BUILD_BUG_ON(offsetof(struct pt_regs, trap) !=
+		     offsetof(struct pt_regs, softe) + sizeof(long));
+
+	membuf_write(&to, &target->thread.ckpt_regs.trap,
+		     sizeof(struct user_pt_regs) - offsetof(struct pt_regs, trap));
  	return membuf_zero(&to, ELF_NGREG * sizeof(unsigned long) -
  			sizeof(struct user_pt_regs));
  }
diff --git a/arch/powerpc/kernel/ptrace/ptrace-view.c  
b/arch/powerpc/kernel/ptrace/ptrace-view.c
index 7e6478e7ed07..736bfbf33890 100644
--- a/arch/powerpc/kernel/ptrace/ptrace-view.c
+++ b/arch/powerpc/kernel/ptrace/ptrace-view.c
@@ -234,9 +234,21 @@ static int gpr_get(struct task_struct *target,  
const struct user_regset *regset,
  	BUILD_BUG_ON(offsetof(struct pt_regs, orig_gpr3) !=
  		     offsetof(struct pt_regs, msr) + sizeof(long));

+#ifdef CONFIG_PPC64
+	membuf_write(&to, &target->thread.regs->orig_gpr3,
+		     offsetof(struct pt_regs, softe) - offsetof(struct pt_regs,  
orig_gpr3));
+	membuf_store(&to, 1UL);
+
+	BUILD_BUG_ON(offsetof(struct pt_regs, trap) !=
+		     offsetof(struct pt_regs, softe) + sizeof(long));
+
+	membuf_write(&to, &target->thread.regs->trap,
+		     sizeof(struct user_pt_regs) - offsetof(struct pt_regs, trap));
+#else
  	membuf_write(&to, &target->thread.regs->orig_gpr3,
  			sizeof(struct user_pt_regs) -
  			offsetof(struct pt_regs, orig_gpr3));
+#endif
  	return membuf_zero(&to, ELF_NGREG * sizeof(unsigned long) -
  				 sizeof(struct user_pt_regs));
  }
---
Christophe

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ