diff mbox series

[v6,13/21] arm64: ptrace: handle ptrace_request differently for aarch32 and ilp32

Message ID 1452209679-19445-14-git-send-email-ynorov@caviumnetworks.com
State New
Headers show
Series None | expand

Commit Message

Yury Norov Jan. 7, 2016, 11:34 p.m. UTC
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>

---
 arch/arm64/kernel/ptrace.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

-- 
2.5.0

Comments

Arnd Bergmann Jan. 8, 2016, 9:01 a.m. UTC | #1
On Friday 08 January 2016 02:34:31 Yury Norov wrote:
> +long compat_arch_ptrace(struct task_struct *child, compat_long_t request,

> +                       compat_ulong_t caddr, compat_ulong_t cdata)

> +{

> +       if (is_a32_compat_task())

> +               return compat_a32_ptrace(child, request, caddr, cdata);

> +

> +       return compat_ptrace_request(child, request, caddr, cdata);

> +}

> +


Looking at this again, I think we can avoid this runtime check
if we duplicate the compat_sys_ptrace function and make a special one
for a32 that is copied from the regular handler and but calls
compat_a32_ptrace directly. Or maybe make a separate handler for
arm64-ilp32 if that is smaller.

	Arnd
diff mbox series

Patch

diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index c166548..f95fb89 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1108,7 +1108,7 @@  static int compat_ptrace_sethbpregs(struct task_struct *tsk, compat_long_t num,
 }
 #endif	/* CONFIG_HAVE_HW_BREAKPOINT */
 
-long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
+long compat_a32_ptrace(struct task_struct *child, compat_long_t request,
 			compat_ulong_t caddr, compat_ulong_t cdata)
 {
 	unsigned long addr = caddr;
@@ -1185,8 +1185,25 @@  long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 	return ret;
 }
+#else
+
+#define compat_a32_ptrace(child, request, caddr, cdata) (-1)
+
 #endif /* CONFIG_AARCH32_EL0 */
 
+#ifdef CONFIG_COMPAT
+
+long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
+			compat_ulong_t caddr, compat_ulong_t cdata)
+{
+	if (is_a32_compat_task())
+		return compat_a32_ptrace(child, request, caddr, cdata);
+
+	return compat_ptrace_request(child, request, caddr, cdata);
+}
+
+#endif /* CONFIG_COMPAT */
+
 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 {
 #ifdef CONFIG_AARCH32_EL0