From: Peter Zijlstra <peterz@infradead.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: tglx@linutronix.de, bp@alien8.de, mingo@kernel.org,
luto@kernel.org, torvalds@linux-foundation.org, hpa@zytor.com,
dave.hansen@linux.intel.com, jgross@suse.com,
linux-kernel@vger.kernel.org, zhe.he@windriver.com,
joel@joelfernandes.org, devel@etsukata.com
Subject: Re: [PATCH 3/3] x86/mm, tracing: Fix CR2 corruption
Date: Wed, 3 Jul 2019 23:51:18 +0200 [thread overview]
Message-ID: <20190703215118.GI3402@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20190703162942.63c750a3@gandalf.local.home>
On Wed, Jul 03, 2019 at 04:29:42PM -0400, Steven Rostedt wrote:
> On Wed, 3 Jul 2019 22:22:31 +0200
> Peter Zijlstra <peterz@infradead.org> wrote:
>
> > On Wed, Jul 03, 2019 at 12:27:34PM +0200, root wrote:
> > > Despire the current efforts to read CR2 before tracing happens there
> > > still exist a number of possible holes:
> > >
> > > idtentry page_fault do_page_fault has_error_code=1
> > > call error_entry
> > > TRACE_IRQS_OFF
> > > call trace_hardirqs_off*
> > > #PF // modifies CR2
> > >
> > > CALL_enter_from_user_mode
> > > __context_tracking_exit()
> > > trace_user_exit(0)
> > > #PF // modifies CR2
> > >
> > > call do_page_fault
> > > address = read_cr2(); /* whoopsie */
> > >
> > > And similar for i386.
> > >
> > > Fix it by pulling the CR2 read into the entry code, before any of that
> > > stuff gets a chance to run and ruin things.
> > >
> > > Ideally we'll clean up the entry code by moving this tracing and
> > > context tracking nonsense into C some day, but let's not delay fixing
> > > this longer.
> > >
> >
> > > @@ -1180,10 +1189,10 @@ idtentry xenint3 do_int3 has_error_co
> > > #endif
> > >
> > > idtentry general_protection do_general_protection has_error_code=1
> > > -idtentry page_fault do_page_fault has_error_code=1
> > > +idtentry page_fault do_page_fault has_error_code=1 read_cr2=1
> > >
> > > #ifdef CONFIG_KVM_GUEST
> > > -idtentry async_page_fault do_async_page_fault has_error_code=1
> > > +idtentry async_page_fault do_async_page_fault has_error_code=1 read_cr2=1
> > > #endif
> >
> > While going over the various idt handlers, I found that we probably also
> > need read_cr2 on do_double_fault(), otherwise it is susceptible to the
> > same problem.
> >
>
> BTW, do you plan on making this for stable? Even though it's rather
> invasive. Or should we just apply the band-aids first, have them
> backported to stable, and then put this change on top of them for
> upstream?
So I don't particularly care about stable; and the band-aids
(trace_irqs_off_cr2) is known broken so I really don't see the point.
That said, these patches should apply to most recent kernels (post PTI)
without too much rejects.
next prev parent reply other threads:[~2019-07-03 21:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 10:27 [PATCH 0/3] tracing vs CR2 root
2019-07-03 10:27 ` [PATCH 1/3] x86/paravirt: Make read_cr2() CALLEE_SAVE root
2019-07-03 14:12 ` Juergen Gross
2019-07-03 10:27 ` [PATCH 2/3] x86/entry/32: Simplify common_exception root
2019-07-03 10:27 ` [PATCH 3/3] x86/mm, tracing: Fix CR2 corruption root
2019-07-03 20:22 ` Peter Zijlstra
2019-07-03 20:29 ` Steven Rostedt
2019-07-03 21:51 ` Peter Zijlstra [this message]
2019-07-03 20:27 ` Andy Lutomirski
2019-07-03 20:47 ` Steven Rostedt
2019-07-03 22:05 ` Peter Zijlstra
2019-07-04 9:19 ` Peter Zijlstra
2019-07-03 22:00 ` Peter Zijlstra
2019-07-03 22:26 ` Andy Lutomirski
2019-07-04 9:13 ` Peter Zijlstra
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=20190703215118.GI3402@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=devel@etsukata.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=zhe.he@windriver.com \
/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
all inboxes | Powered by JetHome®