Adding compat_ptrace_request
Subsystems (3)
Hi,
We noticed 32/64bit compat issues with GETSIGINFO and SETSIGINFO. It looks like s390 are already fixing this up in architecture specific code, but here is a patch from Stephen Rothwell to add some generic compat ptrace helpers.
Look OK?
Anton
--
Subject: [PATCH] compat: add compat_ptrace_request
From: Stephen Rothwell <[email protected]>
This is needed so that we can cope with PTRACE_[GS]ETSIGINFO from 32 bit processes.
---
arch/powerpc/kernel/ptrace32.c +2 -1
@@ -18,6 +18,7 @@*/ #include <linux/config.h> +#include <linux/compat.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -426,7 +427,7 @@#endif default : - ret =ptrace_request (child, request, addr, data); + ret =compat_ptrace_request (child, request, addr, data);break ; } out_tsk:
arch/powerpc/kernel/signal_32.c +11 -3
@@ -621,6 +621,14 @@return ret; } +int copy_siginfo_from_user32 (siginfo_t *to,struct compat_siginfo __user *from) +{ +if (copy_from_user (to, from,3 *sizeof (int )) || +copy_from_user (to->_sifields._pad, from->_sifields._pad, +SI_PAD_SIZE32 )) +return -EFAULT ; +return 0 ; +}int copy_siginfo_to_user32 (struct compat_siginfo __user *d,siginfo_t *s) {
@@ -692,9 +700,9 @@int ret;mm_segment_t old_fs =get_fs (); -if (copy_from_user (&info, uinfo,3 *sizeof (int )) || -copy_from_user (info._sifields._pad, uinfo->_sifields._pad,SI_PAD_SIZE32 )) -return -EFAULT ; + ret =copy_siginfo_from_user32 (&info, uinfo); +if (ret) +return ret;set_fs (KERNEL_DS );/* The __user pointer cast is valid becasuse of the set_fs() */ ret =sys_rt_sigqueueinfo ((int )pid, (int )sig, (siginfo_t __user *) &info);
include/linux/compat.h +5 -0
@@ -161,5 +161,10 @@int get_compat_sigevent (struct sigevent *event,const struct compat_sigevent __user *u_event); +struct task_struct ; + +long compat_ptrace_request (struct task_struct *child,long request, +long addr,long data); +#endif /* CONFIG_COMPAT */ #endif /* _LINUX_COMPAT_H */
kernel/Makefile +1 -1
@@ -19,7 +19,7 @@ obj-$(CONFIG_PM) += power/ obj-$(CONFIG_BSD_PROCESS_ACCT) += acct.o obj-$(CONFIG_KEXEC) += kexec.o -obj-$(CONFIG_COMPAT) += compat.o +obj-$(CONFIG_COMPAT) += compat.o compat_ptrace.o obj-$(CONFIG_CPUSETS) += cpuset.o obj-$(CONFIG_IKCONFIG) += configs.o obj-$(CONFIG_STOP_MACHINE) += stop_machine.o
kernel/compat_ptrace.c new file +91 -0
91 lines not on this page · raw message
From: Anton Blanchard <[email protected]>
Date: Mon, 9 Jan 2006 17:59:14 +1100
Quoted 6 lines
We noticed 32/64bit compat issues with GETSIGINFO and SETSIGINFO. It looks like s390 are already fixing this up in architecture specific code, but here is a patch from Stephen Rothwell to add some generic compat ptrace helpers.
Look OK?
Looks not too bad, although...
kernel/compat_ptrace.c line 38
Quoted 1 line
kernel/compat_ptrace.c new file +1
-0+return copy_siginfo_to_user32 (data, &lastinfo);
It would be nice to rename this copy_siginfo things to not have "32" and instead "compat" in their names.
Quoted 5 lines · On Mon, 09 Jan 2006 01:03:55 -0800 (PST) "David S. Miller"…
kernel/compat_ptrace.c line 38
Quoted 2 lines
kernel/compat_ptrace.c new file +1
-0+return copy_siginfo_to_user32 (data, &lastinfo);It would be nice to rename this
copy_siginfothings to not have "32" and instead "compat" in their names.
I agree entirely. Can I do that as a separate patch on top of this one?
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Quoted 7 lines · Anton Blanchard
Hi,
We noticed 32/64bit compat issues with GETSIGINFO and SETSIGINFO. It looks like s390 are already fixing this up in architecture specific code, but here is a patch from Stephen Rothwell to add some generic compat ptrace helpers.
I think this patch:
http://www.ussg.iu.edu/hypermail/linux/kernel/0601.1/0166.html
makes your patch obsolete ...
although it only handles setsiginfo; should be a one-liner to add getsiginfo too.
From: Stephen Rothwell <[email protected]>
Date: Mon, 9 Jan 2006 23:00:17 +1100
Quoted 8 lines · On Mon, 09 Jan 2006 01:03:55 -0800 (PST) "David S. Miller"…
Quoted 5 lines
kernel/compat_ptrace.c line 38
Quoted 2 lines
kernel/compat_ptrace.c new file +1
-0+return copy_siginfo_to_user32 (data, &lastinfo);It would be nice to rename this
copy_siginfothings to not have "32" and instead "compat" in their names.I agree entirely. Can I do that as a separate patch on top of this one?
Do it seperately if you like.