mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: hpa@zytor.com
To: Linus Torvalds <torvalds@linux-foundation.org>,
	Alexandru Chirvasitu <achirvasub@gmail.com>
Cc: Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	kernel list <linux-kernel@vger.kernel.org>,
	Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: PROBLEM: consolidated IDT invalidation causes kexec to reboot
Date: Tue, 26 Dec 2017 18:25:12 -0800	[thread overview]
Message-ID: <A0C04B15-956D-47C7-ABBA-3D30C2299F62@zytor.com> (raw)
In-Reply-To: <CA+55aFzU8tRSuCoS2TmXjGZ5WRUzMCrG6Jk4eNCQZjP+5sVE9w@mail.gmail.com>

On December 26, 2017 6:16:37 PM PST, Linus Torvalds <torvalds@linux-foundation.org> wrote:
>On Tue, Dec 26, 2017 at 3:19 PM, Alexandru Chirvasitu
><achirvasub@gmail.com> wrote:
>>
>> I went back to the initial problematic commit e802a51 and modified it
>as you suggest:
>
>Thank you.
>
>> This did not work out for me, but now it fails differently. Both
>> (kexec -l + kexec -e) and (kexec -p + echo c > /proc/sysrq-trigger)
>> end in call traces and freezes.
>>
>> It does seem to be tied to idt_invalidate. One of the last things I
>> see on the screen (which is ends up frozen with the computer
>inactive)
>> is
>>
>> EIP: idt_invalidate+0x6/0x40 SS:ESP: 0068:f6c47cd0
>
>Yes, interesting, it's the stack canary load access there:
>
>        mov    %gs:0x14,%edx
>
>that traps.
>
>And that actually makes a lot of sense: the load_segments() call just
>above has rloaded all segments with __KERNEL_DS.
>
>So while the stack canary access *intends* to load it from the magic
>stack canary segment (offset 0x14), we've just reset all segments to
>the standard zero-based full-sized ones, and obviously that will take
>a page fault at 0x14.
>
>And the reason you now actually *see* the page fault is that we
>haven't completely buggered the CPU state now, so the trap handler
>actually works. With the GDT reset before, it used to take that same
>trap, but now the trap handler itself would fault, and cause a triple
>fault - which resets the machine.
>
>So it wasn't actually tracing, it was the stack canary all along. So
>at least it's truly root-caused now.
>
>But the fix is the same: we just can't afford to do any function calls.
>
>Alternatively, we should just fix that insane "load_segments()". I'm
>not sure why the code insists on reloading the segments in the first
>place.
>
>So you could try just to remove the "load_segments()" line entirely.
>
>Thanks for spending the time testing things out,
>
>                     Linus

This is why I personally prefer to see these kinds of terminal stubs written in assembly explicitly: the C compiler simply doesn't have all the information needed to do the right thing.

I'm personally very sceptical to nuking the GDT unless we're in real mode.  There seems to be no point, and just opens up failure modes.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

  reply	other threads:[~2017-12-27  2:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-24  1:44 Alexandru Chirvasitu
2017-12-24  3:30 ` Linus Torvalds
2017-12-24  7:28   ` Alexandru Chirvasitu
2017-12-24 11:28     ` Ingo Molnar
2017-12-24 15:27       ` Alexandru Chirvasitu
2017-12-24 16:40         ` Alexandru Chirvasitu
2017-12-25  9:47         ` Ingo Molnar
2017-12-25 14:40   ` Andy Lutomirski
2017-12-25 21:29     ` Alexandru Chirvasitu
2017-12-26 18:51       ` Linus Torvalds
2017-12-26 19:26         ` hpa
2017-12-26 23:19         ` Alexandru Chirvasitu
2017-12-26 23:39           ` hpa
2017-12-26 23:40           ` hpa
2017-12-26 23:45           ` hpa
2017-12-27  2:16           ` Linus Torvalds
2017-12-27  2:25             ` hpa [this message]
2017-12-27  2:54               ` Linus Torvalds
2017-12-27  3:00                 ` hpa
2017-12-28  1:30                   ` Konrad Rzeszutek Wilk
2017-12-27  4:41             ` Alexandru Chirvasitu

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=A0C04B15-956D-47C7-ABBA-3D30C2299F62@zytor.com \
    --to=hpa@zytor.com \
    --cc=achirvasub@gmail.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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

all inboxes | Powered by JetHome®