aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/compat.h7
-rw-r--r--kernel/ptrace.c46
2 files changed, 53 insertions, 0 deletions
diff --git a/include/linux/compat.h b/include/linux/compat.h
index a907fbede6c3..d38655f2be70 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -247,6 +247,13 @@ extern int compat_ptrace_request(struct task_struct *child,
247 compat_long_t request, 247 compat_long_t request,
248 compat_ulong_t addr, compat_ulong_t data); 248 compat_ulong_t addr, compat_ulong_t data);
249 249
250#ifdef __ARCH_WANT_COMPAT_SYS_PTRACE
251extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
252 compat_ulong_t addr, compat_ulong_t data);
253asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
254 compat_long_t addr, compat_long_t data);
255#endif /* __ARCH_WANT_COMPAT_SYS_PTRACE */
256
250/* 257/*
251 * epoll (fs/eventpoll.c) compat bits follow ... 258 * epoll (fs/eventpoll.c) compat bits follow ...
252 */ 259 */
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index ed1c3d56c2cd..e6e9b8be4b05 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -644,4 +644,50 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
644 644
645 return ret; 645 return ret;
646} 646}
647
648#ifdef __ARCH_WANT_COMPAT_SYS_PTRACE
649asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
650 compat_long_t addr, compat_long_t data)
651{
652 struct task_struct *child;
653 long ret;
654
655 /*
656 * This lock_kernel fixes a subtle race with suid exec
657 */
658 lock_kernel();
659 if (request == PTRACE_TRACEME) {
660 ret = ptrace_traceme();
661 goto out;
662 }
663
664 child = ptrace_get_task_struct(pid);
665 if (IS_ERR(child)) {
666 ret = PTR_ERR(child);
667 goto out;
668 }
669
670 if (request == PTRACE_ATTACH) {
671 ret = ptrace_attach(child);
672 /*
673 * Some architectures need to do book-keeping after
674 * a ptrace attach.
675 */
676 if (!ret)
677 arch_ptrace_attach(child);
678 goto out_put_task_struct;
679 }
680
681 ret = ptrace_check_attach(child, request == PTRACE_KILL);
682 if (!ret)
683 ret = compat_arch_ptrace(child, request, addr, data);
684
685 out_put_task_struct:
686 put_task_struct(child);
687 out:
688 unlock_kernel();
689 return ret;
690}
691#endif /* __ARCH_WANT_COMPAT_SYS_PTRACE */
692
647#endif /* CONFIG_COMPAT */ 693#endif /* CONFIG_COMPAT */