public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Andy Lutomirski <luto@kernel.org>,
	Andrey Vagin <avagin@virtuozzo.com>,
	Dmitry Safonov <dsafonov@virtuozzo.com>
Cc: Nadav Amit <nadav.amit@gmail.com>,
	Pavel Emelyanov <xemul@parallels.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Willy Tarreau <w@1wt.eu>, X86 ML <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFC v2 4/6] x86: Disable PTI on compatibility mode
Date: Fri, 16 Feb 2018 10:11:39 +0300	[thread overview]
Message-ID: <20180216071139.GC32767@uranus> (raw)
In-Reply-To: <CALCETrVP3BaOapL3eS8Tf=KFeM8VFPqvMoECGRkFa7WPLq=Asw@mail.gmail.com>

On Thu, Feb 15, 2018 at 11:29:42PM +0000, Andy Lutomirski wrote:
...
> >>> +bool pti_handle_segment_not_present(long error_code)
> >>> +{
> >>> +       if (!static_cpu_has(X86_FEATURE_PTI))
> >>> +               return false;
> >>> +
> >>> +       if ((unsigned short)error_code != GDT_ENTRY_DEFAULT_USER_CS << 3)
> >>> +               return false;
> >>> +
> >>> +       pti_reenable();
> >>> +       return true;
> >>> +}
> >>
> >> Please don't.  You're trying to emulate the old behavior here, but
> >> you're emulating it wrong.  In particular, you won't trap on LAR.
> >
> > Yes, I thought I’ll manage to address LAR, but failed. I thought you said
> > this is not a “show-stopper”. I’ll adapt your approach of using prctl, although
> > it really limits the benefit of this mechanism.
> >
> 
> It's possible we could get away with adding the prctl but making the
> default be that only the bitness that matches the program being run is
> allowed.  After all, it's possible that CRIU is literally the only
> program that switches bitness using the GDT.  (DOSEMU2 definitely does
> cross-bitness stuff, but it uses the LDT as far as I know.)  And I've
> never been entirely sure that CRIU fully counts toward the Linux
> "don't break ABI" guarantee.
> 
> Linus, how would you feel about, by default, preventing 64-bit
> programs from long-jumping to __USER32_CS and vice versa?  I think it
> has some value as a hardening measure.  I've certainly engaged in some
> exploit shenanigans myself that took advantage of the ability to long
> jump/ret to change bitness at will.  This wouldn't affect users of
> modify_ldt() -- 64-bit programs could still create and use their own
> private 32-bit segments with modify_ldt(), and seccomp can (and
> should!) prevent that in sandboxed programs.
> 
> In general, I prefer an approach where everything is explicit to an
> approach where we almost, but not quite, emulate the weird historical
> behavior.
> 
> Pavel and Cyrill, how annoying would it be if CRIU had to do an extra
> arch_prctl() to enable its cross-bitness shenanigans when
> checkpointing and restoring a 32-bit program?

I think this should not be a problem for criu (CC'ing Dima, who has
been working on compat mode support in criu). As far as I remember
we initiate restoring of 32 bit tasks in native 64 bit mode (well,
ia32e to be precise :) mode and then, once everything is ready,
we changing the mode by doing a return to __USER32_CS descriptor.
So this won't be painful to add additional prctl call here.

  parent reply	other threads:[~2018-02-16  7:11 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 16:35 [PATCH RFC v2 0/6] x86: Disabling PTI in compatibility mode Nadav Amit
2018-02-15 16:35 ` [PATCH RFC v2 1/6] x86: Skip PTI when disable indication is set Nadav Amit
2018-02-15 18:10   ` Dave Hansen
2018-02-15 19:51   ` Andy Lutomirski
2018-02-15 20:51     ` Nadav Amit
2018-02-15 23:35       ` Andy Lutomirski
2018-02-15 16:35 ` [PATCH RFC v2 2/6] x86: Save pti_disable for each mm_context Nadav Amit
2018-02-15 16:35 ` [PATCH RFC v2 3/6] x86: Switching page-table isolation Nadav Amit
2018-02-15 16:36 ` [PATCH RFC v2 4/6] x86: Disable PTI on compatibility mode Nadav Amit
2018-02-15 20:02   ` Andy Lutomirski
2018-02-15 20:58     ` Nadav Amit
2018-02-15 23:29       ` Andy Lutomirski
2018-02-16  0:08         ` Linus Torvalds
2018-02-16  0:22           ` Nadav Amit
2018-02-16  0:42             ` Linus Torvalds
2018-02-16  3:03               ` Andy Lutomirski
2018-02-16  4:55                 ` Nadav Amit
2018-02-16  0:35           ` Andrew Cooper
2018-02-16 15:20           ` Andy Lutomirski
2018-02-16  7:11         ` Cyrill Gorcunov [this message]
2018-02-16 22:07           ` Dmitry Safonov
2018-02-16 22:11             ` Nadav Amit
2018-02-16 16:25     ` Dmitry Safonov
2018-02-15 16:36 ` [PATCH RFC v2 5/6] x86: Use global pages when PTI is disabled Nadav Amit
2018-02-15 16:54   ` Dave Hansen
2018-02-15 17:36     ` Nadav Amit
2018-02-15 17:47     ` Nadav Amit
2018-02-15 18:08       ` Dave Hansen
2018-02-15 19:53   ` Andy Lutomirski
2018-02-15 20:32     ` Dave Hansen
2018-02-15 20:45       ` Nadav Amit
2018-02-15 16:36 ` [PATCH RFC v2 6/6] selftest: x86: test using CS64 on compatibility-mode Nadav Amit
2018-02-16  0:21 ` [PATCH RFC v2 0/6] x86: Disabling PTI in compatibility mode Dave Hansen
2018-02-16  0:25   ` Nadav Amit
2018-02-16  0:42     ` Dave Hansen
2018-02-16  0:48       ` Nadav Amit
2018-02-16  0:45     ` Andrew Cooper
2018-02-16  0:51       ` Nadav Amit
2018-02-16  1:04         ` Andrew Cooper
2018-02-16  3:05         ` 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=20180216071139.GC32767@uranus \
    --to=gorcunov@gmail.com \
    --cc=avagin@virtuozzo.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dsafonov@virtuozzo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=nadav.amit@gmail.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=w@1wt.eu \
    --cc=x86@kernel.org \
    --cc=xemul@parallels.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