From: Roland McGrath <roland@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org
Subject: [PATCH -mm 09/43] compat_sys_ptrace
Date: Thu, 20 Dec 2007 03:55:51 -0800 (PST) [thread overview]
Message-ID: <20071220115551.73EE026F98B@magilla.localdomain> (raw)
In-Reply-To: Roland McGrath's message of Thursday, 20 December 2007 03:52:00 -0800 <20071220115200.C767E26F98A@magilla.localdomain>
This adds a generic definition of compat_sys_ptrace that calls
compat_arch_ptrace, parallel to sys_ptrace/arch_ptrace. Some
machines needing this already define a function by that name.
The new generic function is defined only on machines that
put #define __ARCH_WANT_COMPAT_SYS_PTRACE into asm/ptrace.h.
Signed-off-by: Roland McGrath <roland@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
include/linux/compat.h | 7 +++++++
kernel/ptrace.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index e70a2a1..aa3a55e 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -275,5 +275,12 @@ extern int compat_ptrace_request(struct task_struct *child,
compat_long_t request,
compat_ulong_t addr, compat_ulong_t data);
+#ifdef __ARCH_WANT_COMPAT_SYS_PTRACE
+extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
+ compat_ulong_t addr, compat_ulong_t data);
+asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
+ compat_long_t addr, compat_long_t data);
+#endif /* __ARCH_WANT_COMPAT_SYS_PTRACE */
+
#endif /* CONFIG_COMPAT */
#endif /* _LINUX_COMPAT_H */
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index bc1a764..319ab4a 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -642,4 +642,50 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
return ret;
}
+
+#ifdef __ARCH_WANT_COMPAT_SYS_PTRACE
+asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
+ compat_long_t addr, compat_long_t data)
+{
+ struct task_struct *child;
+ long ret;
+
+ /*
+ * This lock_kernel fixes a subtle race with suid exec
+ */
+ lock_kernel();
+ if (request == PTRACE_TRACEME) {
+ ret = ptrace_traceme();
+ goto out;
+ }
+
+ child = ptrace_get_task_struct(pid);
+ if (IS_ERR(child)) {
+ ret = PTR_ERR(child);
+ goto out;
+ }
+
+ if (request == PTRACE_ATTACH) {
+ ret = ptrace_attach(child);
+ /*
+ * Some architectures need to do book-keeping after
+ * a ptrace attach.
+ */
+ if (!ret)
+ arch_ptrace_attach(child);
+ goto out_put_task_struct;
+ }
+
+ ret = ptrace_check_attach(child, request == PTRACE_KILL);
+ if (!ret)
+ ret = compat_arch_ptrace(child, request, addr, data);
+
+ out_put_task_struct:
+ put_task_struct(child);
+ out:
+ unlock_kernel();
+ return ret;
+}
+#endif /* __ARCH_WANT_COMPAT_SYS_PTRACE */
+
#endif /* CONFIG_COMPAT */
--
1.5.3.6
next prev parent reply other threads:[~2007-12-20 11:56 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-20 11:52 [PATCH -mm 00/43] user_regset framework -- arch maintainers take note! Roland McGrath
2007-12-20 11:53 ` [PATCH -mm 01/43] user_regset header Roland McGrath
2007-12-21 7:06 ` Christoph Hellwig
2007-12-21 8:44 ` Roland McGrath
2007-12-21 10:26 ` Peter Zijlstra
2007-12-21 11:08 ` David Woodhouse
2007-12-20 11:54 ` [PATCH -mm 02/43] elf core dump: notes reorg Roland McGrath
2007-12-20 11:54 ` [PATCH -mm 03/43] elf core dump: notes user_regset Roland McGrath
2007-12-20 11:54 ` [PATCH -mm 04/43] user_regset helpers Roland McGrath
2007-12-20 11:54 ` [PATCH -mm 05/43] compat_binfmt_elf Roland McGrath
2007-12-21 12:55 ` Arnd Bergmann
2007-12-20 11:55 ` [PATCH -mm 06/43] user_regset user-copy helpers Roland McGrath
2007-12-20 11:55 ` [PATCH -mm 07/43] ptrace_request peekdata/pokedata Roland McGrath
2007-12-20 11:55 ` [PATCH -mm 08/43] compat_ptrace_request Roland McGrath
2007-12-20 11:55 ` Roland McGrath [this message]
2007-12-21 7:11 ` [PATCH -mm 09/43] compat_sys_ptrace Christoph Hellwig
2007-12-21 8:52 ` Roland McGrath
2007-12-20 11:57 ` [PATCH -mm 10/43] powerpc user_regset fpregs Roland McGrath
2007-12-20 11:57 ` [PATCH -mm 11/43] powerpc user_regset altivec Roland McGrath
2007-12-20 11:57 ` [PATCH -mm 12/43] powerpc user_regset spe Roland McGrath
2007-12-20 11:57 ` [PATCH -mm 13/43] powerpc ptrace special regs Roland McGrath
2007-12-20 11:57 ` [PATCH -mm 14/43] powerpc user_regset gpr Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 15/43] powerpc user_regset_view Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 16/43] powerpc user_regset compat Roland McGrath
2008-01-07 5:40 ` [PATCH update " Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 17/43] powerpc CORE_DUMP_USE_REGSET Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 18/43] powerpc compat_binfmt_elf Roland McGrath
2007-12-21 7:12 ` Christoph Hellwig
2007-12-21 8:56 ` Roland McGrath
2007-12-21 17:51 ` Kyle McMartin
2007-12-21 19:36 ` Arnd Bergmann
2007-12-21 20:00 ` Sam Ravnborg
2007-12-20 11:58 ` [PATCH -mm 19/43] powerpc core dump cleanup Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 20/43] powerpc SPE core dump Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 21/43] powerpc ptrace user_regset Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 22/43] powerpc ptrace generic peekdata/pokedata Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 23/43] powerpc compat_ptrace_request Roland McGrath
2007-12-20 11:58 ` [PATCH -mm 24/43] powerpc compat_sys_ptrace Roland McGrath
2007-12-20 11:59 ` [PATCH -mm 25/43] powerpc ptrace32 user_regset Roland McGrath
2007-12-20 13:00 ` [PATCH -mm 00/43] user_regset framework -- arch maintainers take note! Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071220115551.73EE026F98B@magilla.localdomain \
--to=roland@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox