linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Andy Lutomirski <luto@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Lai Jiangshan <laijs@linux.alibaba.com>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	the arch/x86 maintainers <x86@kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>, Juergen Gross <jgross@suse.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Arvind Sankar <nivedita@alum.mit.edu>
Subject: Re: [RFC PATCH 1/4] x86/entry/nmi: Switch to the entry stack before switching to the thread stack
Date: Fri, 25 Jun 2021 12:40:53 +0200	[thread overview]
Message-ID: <YNWytd64PzMwZKQX@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <444d7139-e47a-4831-93d0-8eb5b9680fdc@www.fastmail.com>

On Sat, Jun 19, 2021 at 08:13:15PM -0700, Andy Lutomirski wrote:
> 
> 
> On Sat, Jun 19, 2021, at 3:51 PM, Thomas Gleixner wrote:
> > On Tue, Jun 01 2021 at 14:52, Lai Jiangshan wrote:
> > > From: Lai Jiangshan <laijs@linux.alibaba.com>
> > >
> > > Current kernel has no code to enforce data breakpoint not on the thread
> > > stack.  If there is any data breakpoint on the top area of the thread
> > > stack, there might be problem.
> > 
> > And because the kernel does not prevent data breakpoints on the thread
> > stack we need to do more complicated things in the already horrible
> > entry code instead of just doing the obvious and preventing data
> > breakpoints on the thread stack?
> 
> Preventing breakpoints on the thread stack is a bit messy: it’s
> possible for a breakpoint to be set before the address in question is
> allocated for the thread stack.

How about we call into C from the entry stack and have the from-user
stack swizzle there. The from-kernel entries land on the ISTs and those
are already excluded.

> None of this is NMI-specific. #DB itself has the same problem.  We
> could plausibly solve it differently by disarming breakpoints in the
> entry asm before switching stacks. I’m not sure how much I like that
> approach.

I'm not sure I see how, from-user #DB already doesn't clear DR7, and if
we recurse, we'll get a from-kernel trap, which will land on the IST,
whcih is excluded, and then we clear DR7 there.

IST and entry stack are excluded, the only problem we have is thread
stack, and that can be solved by calling into C from the entry stack.

I should put teaching objtool about .data references from .noinstr.text
and .entry.text higher on the todo list I suppose ...

  parent reply	other threads:[~2021-06-25 10:41 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01  6:52 [RFC PATCH 0/4] x86/entry/nmi: solidify userspace NMI entry Lai Jiangshan
2021-06-01  6:52 ` [RFC PATCH 1/4] x86/entry/nmi: Switch to the entry stack before switching to the thread stack Lai Jiangshan
2021-06-01 17:05   ` Steven Rostedt
2021-06-02  0:09     ` Lai Jiangshan
2021-06-02  0:16     ` Lai Jiangshan
2021-06-19 22:51   ` Thomas Gleixner
2021-06-20  3:13     ` Andy Lutomirski
2021-06-20 11:23       ` Thomas Gleixner
2021-06-25 10:40       ` Peter Zijlstra [this message]
2021-06-25 11:00         ` Peter Zijlstra
2021-06-26  7:03           ` Thomas Gleixner
2021-06-26  8:28             ` Peter Zijlstra
2021-06-01  6:52 ` [RFC PATCH 2/4] x86/entry/nmi: Use normal idtentry macro for NMI from userspace Lai Jiangshan
2021-06-03 17:36   ` Andy Lutomirski
2021-06-01  6:52 ` [RFC PATCH 3/4] x86/entry: Remove parameter rdx from macro PUSH_AND_CLEAR_REGS and PUSH_REGS Lai Jiangshan
2021-06-01  6:52 ` [RFC PATCH 4/4] x86/entry/nmi: unmask NMIs on userspace NMI when entry debugging Lai Jiangshan
2021-06-03 17:38   ` Andy Lutomirski

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=YNWytd64PzMwZKQX@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jiangshanlai@gmail.com \
    --cc=laijs@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nivedita@alum.mit.edu \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=x86@kernel.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;
as well as URLs for NNTP newsgroup(s).