From: David Laight <David.Laight@ACULAB.COM>
To: "'Andy Lutomirski'" <luto@amacapital.net>,
Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>,
Jarkko Nikula <jarkko.nikula@linux.intel.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Andy Lutomirski <luto@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Borislav Petkov <bp@alien8.de>
Subject: RE: [PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled
Date: Wed, 29 Nov 2017 14:56:43 +0000 [thread overview]
Message-ID: <4f2c1cf45fd04e83a7d360d0d602830e@AcuMS.aculab.com> (raw)
In-Reply-To: <D6A6B532-57B5-4393-A322-DD441BEE74C4@amacapital.net>
From: Andy Lutomirski
> Sent: 29 November 2017 14:34
> > On Nov 29, 2017, at 4:47 AM, Peter Zijlstra <peterz@infradead.org> wrote:
> >
> >> On Wed, Nov 29, 2017 at 08:09:51AM +0100, Ingo Molnar wrote:
> >> diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> >> index f81d50d7ceac..c0b52df8ee4f 100644
> >> --- a/arch/x86/entry/entry_64.S
> >> +++ b/arch/x86/entry/entry_64.S
> >> @@ -945,16 +945,16 @@ idtentry simd_coprocessor_error do_simd_coprocessor_error
> has_error_code=0
> >> */
> >> ENTRY(native_load_gs_index)
> >> FRAME_BEGIN
> >> + SWAPGS /* switch from user GS to kernel GS */
> >> pushfq
> >> DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
> >> TRACE_IRQS_OFF
> >> - SWAPGS
> >
> > I'm thinking those moves it too far back; we should at least have
> > interrupts disabled when we do SWAPGS, no? Also, curse paravirt.
> >
>
> I'll look in a few hours.
>
> But we definitely can't have irqs on when running with user gs.
I can't remember what happens when swapgs itself faults.
I'm pretty sure it can, restoring %ds %es and %fs can definitely fault
(especially for 32 bit apps) if the restored values are invalid.
With user LDT I think it is possible for a valid segment register
to become invalid while a process is sleeping.
The debugger (and possible a signal handler) can set the segment
registers to arbitrary values - so loading them faults.
I fixed NetBSD a few years ago so that all these faults were handled
correctly.
David
next prev parent reply other threads:[~2017-11-29 14:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-28 14:35 Suspend-to-ram/resume regression with commit ca37e57bbe0c Jarkko Nikula
2017-11-29 7:09 ` [PATCH] x86/entry/64: Fix native_load_gs_index() SWAPGS handling with IRQ state tracing enabled Ingo Molnar
2017-11-29 9:25 ` Jarkko Nikula
2017-11-29 9:28 ` Thomas Gleixner
2017-11-29 12:39 ` Jarkko Nikula
2017-11-29 12:47 ` Peter Zijlstra
2017-11-29 14:33 ` Andy Lutomirski
2017-11-29 14:56 ` David Laight [this message]
2017-11-29 16:22 ` Andy Lutomirski
2017-11-29 16:51 ` David Laight
2017-11-29 20:48 ` Linus Torvalds
2017-11-29 16:51 ` Andy Lutomirski
2017-11-29 17:57 ` Andy Lutomirski
2017-11-29 18:08 ` Peter Zijlstra
2017-11-29 18:12 ` Andy Lutomirski
2017-11-29 20:58 ` Linus Torvalds
2017-11-29 21:25 ` Andy Lutomirski
2017-11-29 21:41 ` Andy Lutomirski
2017-11-29 21:57 ` Andy Lutomirski
2017-11-30 8:42 ` Jarkko Nikula
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=4f2c1cf45fd04e83a7d360d0d602830e@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=bp@alien8.de \
--cc=jarkko.nikula@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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
Powered by JetHome