[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAP045AqWZQ93+cpXTDpNws-Rv15t=tAJMx3WsuRvL4-63oPw0w@mail.gmail.com>
Date: Tue, 27 Oct 2020 10:22:34 -0700
From: Kyle Huey <me@...ehuey.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Andy Lutomirski <luto@...nel.org>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" <x86@...nel.org>,
open list <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
"Robert O'Callahan" <rocallahan@...il.com>,
Alexandre Chartre <alexandre.chartre@...cle.com>,
"Paul E. McKenney" <paulmck@...nel.org>,
Frederic Weisbecker <frederic@...nel.org>,
Paolo Bonzini <pbonzini@...hat.com>,
Sean Christopherson <sean.j.christopherson@...el.com>,
Masami Hiramatsu <mhiramat@...nel.org>,
Petr Mladek <pmladek@...e.com>,
Joel Fernandes <joel@...lfernandes.org>,
Steven Rostedt <rostedt@...dmis.org>,
Boris Ostrovsky <boris.ostrovsky@...cle.com>,
Juergen Gross <jgross@...e.com>,
Brian Gerst <brgerst@...il.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
Daniel Thompson <daniel.thompson@...aro.org>,
julliard@...ehq.org, pgofman@...eweavers.com
Subject: Re: [PATCH 3/3] x86/debug: Fix PTRACE_{BLOCK,SINGLE}STEP vs ptrace_get_debugreg(6)
On Tue, Oct 27, 2020 at 2:44 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> Commit d53d9bc0cf78 ("x86/debug: Change thread.debugreg6 to
> thread.virtual_dr6") changed the semantics of the variable from random
> collection of bits, to exactly only those bits that ptrace() needs.
>
> Unfortunately we lost DR_STEP for PTRACE_{BLOCK,SINGLE}STEP.
>
> Fixes: d53d9bc0cf78 ("x86/debug: Change thread.debugreg6 to thread.virtual_dr6")
> Reported-by: Kyle Huey <me@...ehuey.com>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> ---
> arch/x86/include/asm/ptrace.h | 2 ++
> arch/x86/kernel/step.c | 9 +++++++++
> arch/x86/kernel/traps.c | 2 +-
> 3 files changed, 12 insertions(+), 1 deletion(-)
>
> --- a/arch/x86/include/asm/ptrace.h
> +++ b/arch/x86/include/asm/ptrace.h
> @@ -355,6 +355,8 @@ static inline unsigned long regs_get_ker
> #define arch_has_block_step() (boot_cpu_data.x86 >= 6)
> #endif
>
> +extern unsigned long user_dr_step(unsigned long dr6);
> +
> #define ARCH_HAS_USER_SINGLE_STEP_REPORT
>
> struct user_desc;
> --- a/arch/x86/kernel/step.c
> +++ b/arch/x86/kernel/step.c
> @@ -235,3 +235,12 @@ void user_disable_single_step(struct tas
> if (test_and_clear_tsk_thread_flag(child, TIF_FORCED_TF))
> task_pt_regs(child)->flags &= ~X86_EFLAGS_TF;
> }
> +
> +unsigned long user_dr_step(unsigned long dr6)
> +{
> + if (test_thread_flag(TIF_BLOCKSTEP) ||
> + test_thread_flag(TIF_SINGLESTEP))
> + return dr6 & DR_STEP;
> +
> + return 0;
> +}
> --- a/arch/x86/kernel/traps.c
> +++ b/arch/x86/kernel/traps.c
> @@ -940,7 +940,7 @@ static __always_inline void exc_debug_us
> * Clear the virtual DR6 value, ptrace() routines will set bits here
> * for things it wants signals for.
> */
> - current->thread.virtual_dr6 = 0;
> + current->thread.virtual_dr6 = user_dr_step(dr6);
>
> /*
> * The SDM says "The processor clears the BTF flag when it
>
>
Tested-by: Kyle Huey <me@...ehuey.com>
Confirmed that this patch series fixes rr when applied on top of the
v5.10-rc1 tag.
- Kyle
Powered by blists - more mailing lists