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, 15 insertions, 25 deletions
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
index 7a98b21945aa..0649f166d7c6 100644
--- a/arch/x86/kernel/ptrace.c
+++ b/arch/x86/kernel/ptrace.c
@@ -637,9 +637,7 @@ static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data)
637 struct thread_struct *thread = &(tsk->thread); 637 struct thread_struct *thread = &(tsk->thread);
638 unsigned long old_dr7; 638 unsigned long old_dr7;
639 int i, orig_ret = 0, rc = 0; 639 int i, orig_ret = 0, rc = 0;
640 int enabled, second_pass = 0; 640 int second_pass = 0;
641 unsigned len, type;
642 struct perf_event *bp;
643 641
644 data &= ~DR_CONTROL_RESERVED; 642 data &= ~DR_CONTROL_RESERVED;
645 old_dr7 = ptrace_get_dr7(thread->ptrace_bps); 643 old_dr7 = ptrace_get_dr7(thread->ptrace_bps);
@@ -649,30 +647,22 @@ restore:
649 * appropriate changes to each. 647 * appropriate changes to each.
650 */ 648 */
651 for (i = 0; i < HBP_NUM; i++) { 649 for (i = 0; i < HBP_NUM; i++) {
652 enabled = decode_dr7(data, i, &len, &type); 650 unsigned len, type;
653 bp = thread->ptrace_bps[i]; 651 bool disabled = !decode_dr7(data, i, &len, &type);
654 652 struct perf_event *bp = thread->ptrace_bps[i];
655 if (!enabled) { 653
656 if (bp) { 654 if (disabled) {
657 /* 655 /*
658 * Don't unregister the breakpoints right-away, 656 * Don't unregister the breakpoints right-away, unless
659 * unless all register_user_hw_breakpoint() 657 * all register_user_hw_breakpoint() requests have
660 * requests have succeeded. This prevents 658 * succeeded. This prevents any window of opportunity
661 * any window of opportunity for debug 659 * for debug register grabbing by other users.
662 * register grabbing by other users. 660 */
663 */ 661 if (!bp || !second_pass)
664 if (!second_pass) 662 continue;
665 continue;
666
667 rc = ptrace_modify_breakpoint(bp, len, type,
668 tsk, 1);
669 if (rc)
670 break;
671 }
672 continue;
673 } 663 }
674 664
675 rc = ptrace_modify_breakpoint(bp, len, type, tsk, 0); 665 rc = ptrace_modify_breakpoint(bp, len, type, tsk, disabled);
676 if (rc) 666 if (rc)
677 break; 667 break;
678 } 668 }