aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/ptrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/ptrace.c')
-rw-r--r--arch/x86/kernel/ptrace.c40
1 files changed, 9 insertions, 31 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 58ce4b50211b..e375b658efc3 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -14,6 +14,7 @@
14#include <linux/errno.h> 14#include <linux/errno.h>
15#include <linux/ptrace.h> 15#include <linux/ptrace.h>
16#include <linux/regset.h> 16#include <linux/regset.h>
17#include <linux/tracehook.h>
17#include <linux/user.h> 18#include <linux/user.h>
18#include <linux/elf.h> 19#include <linux/elf.h>
19#include <linux/security.h> 20#include <linux/security.h>
@@ -734,7 +735,7 @@ static int ptrace_bts_config(struct task_struct *child,
734 goto errout; 735 goto errout;
735 736
736 if (cfg.flags & PTRACE_BTS_O_ALLOC) { 737 if (cfg.flags & PTRACE_BTS_O_ALLOC) {
737 ds_ovfl_callback_t ovfl = 0; 738 ds_ovfl_callback_t ovfl = NULL;
738 unsigned int sig = 0; 739 unsigned int sig = 0;
739 740
740 /* we ignore the error in case we were not tracing child */ 741 /* we ignore the error in case we were not tracing child */
@@ -748,7 +749,7 @@ static int ptrace_bts_config(struct task_struct *child,
748 ovfl = ptrace_bts_ovfl; 749 ovfl = ptrace_bts_ovfl;
749 } 750 }
750 751
751 error = ds_request_bts(child, /* base = */ 0, cfg.size, ovfl); 752 error = ds_request_bts(child, /* base = */ NULL, cfg.size, ovfl);
752 if (error < 0) 753 if (error < 0)
753 goto errout; 754 goto errout;
754 755
@@ -1086,7 +1087,7 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
1086 break; 1087 break;
1087 1088
1088 case PTRACE_BTS_SIZE: 1089 case PTRACE_BTS_SIZE:
1089 ret = ds_get_bts_index(child, /* pos = */ 0); 1090 ret = ds_get_bts_index(child, /* pos = */ NULL);
1090 break; 1091 break;
1091 1092
1092 case PTRACE_BTS_GET: 1093 case PTRACE_BTS_GET:
@@ -1469,30 +1470,6 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
1469 force_sig_info(SIGTRAP, &info, tsk); 1470 force_sig_info(SIGTRAP, &info, tsk);
1470} 1471}
1471 1472
1472static void syscall_trace(struct pt_regs *regs)
1473{
1474 if (!(current->ptrace & PT_PTRACED))
1475 return;
1476
1477#if 0
1478 printk("trace %s ip %lx sp %lx ax %d origrax %d caller %lx tiflags %x ptrace %x\n",
1479 current->comm,
1480 regs->ip, regs->sp, regs->ax, regs->orig_ax, __builtin_return_address(0),
1481 current_thread_info()->flags, current->ptrace);
1482#endif
1483
1484 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1485 ? 0x80 : 0));
1486 /*
1487 * this isn't the same as continuing with a signal, but it will do
1488 * for normal use. strace only continues with a signal if the
1489 * stopping signal is not SIGTRAP. -brl
1490 */
1491 if (current->exit_code) {
1492 send_sig(current->exit_code, current, 1);
1493 current->exit_code = 0;
1494 }
1495}
1496 1473
1497#ifdef CONFIG_X86_32 1474#ifdef CONFIG_X86_32
1498# define IS_IA32 1 1475# define IS_IA32 1
@@ -1526,8 +1503,9 @@ asmregparm long syscall_trace_enter(struct pt_regs *regs)
1526 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU))) 1503 if (unlikely(test_thread_flag(TIF_SYSCALL_EMU)))
1527 ret = -1L; 1504 ret = -1L;
1528 1505
1529 if (ret || test_thread_flag(TIF_SYSCALL_TRACE)) 1506 if ((ret || test_thread_flag(TIF_SYSCALL_TRACE)) &&
1530 syscall_trace(regs); 1507 tracehook_report_syscall_entry(regs))
1508 ret = -1L;
1531 1509
1532 if (unlikely(current->audit_context)) { 1510 if (unlikely(current->audit_context)) {
1533 if (IS_IA32) 1511 if (IS_IA32)
@@ -1553,7 +1531,7 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
1553 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax); 1531 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
1554 1532
1555 if (test_thread_flag(TIF_SYSCALL_TRACE)) 1533 if (test_thread_flag(TIF_SYSCALL_TRACE))
1556 syscall_trace(regs); 1534 tracehook_report_syscall_exit(regs, 0);
1557 1535
1558 /* 1536 /*
1559 * If TIF_SYSCALL_EMU is set, we only get here because of 1537 * If TIF_SYSCALL_EMU is set, we only get here because of
@@ -1569,6 +1547,6 @@ asmregparm void syscall_trace_leave(struct pt_regs *regs)
1569 * system call instruction. 1547 * system call instruction.
1570 */ 1548 */
1571 if (test_thread_flag(TIF_SINGLESTEP) && 1549 if (test_thread_flag(TIF_SINGLESTEP) &&
1572 (current->ptrace & PT_PTRACED)) 1550 tracehook_consider_fatal_signal(current, SIGTRAP, SIG_DFL))
1573 send_sigtrap(current, regs, 0); 1551 send_sigtrap(current, regs, 0);
1574} 1552}