linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-tip-commits@vger.kernel.org,
	Andy Lutomirski <luto@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>, x86 <x86@kernel.org>
Subject: Re: [tip: x86/urgent] x86/entry, selftests: Further improve user entry sanity checks
Date: Sat, 22 Aug 2020 14:59:37 -0700	[thread overview]
Message-ID: <CALCETrVFQuMcUgfDkREGFHSSF9UW5yy4UuNZSpjw1962eSvLyw@mail.gmail.com> (raw)
In-Reply-To: <20200820102344.GP2674@hirez.programming.kicks-ass.net>

On Thu, Aug 20, 2020 at 3:24 AM <peterz@infradead.org> wrote:
>
> On Sat, Jul 04, 2020 at 05:49:10PM -0000, tip-bot2 for Andy Lutomirski wrote:
>
> > diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
> > index f392a8b..e83b3f1 100644
> > --- a/arch/x86/entry/common.c
> > +++ b/arch/x86/entry/common.c
> > @@ -49,6 +49,23 @@
> >  static void check_user_regs(struct pt_regs *regs)
> >  {
> >       if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) {
> > +             /*
> > +              * Make sure that the entry code gave us a sensible EFLAGS
> > +              * register.  Native because we want to check the actual CPU
> > +              * state, not the interrupt state as imagined by Xen.
> > +              */
> > +             unsigned long flags = native_save_fl();
> > +             WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
> > +                                   X86_EFLAGS_NT));
>
> This triggers with AC|TF on my !SMAP enabled machine.
>
> something like so then?
>
> diff --git a/arch/x86/include/asm/entry-common.h b/arch/x86/include/asm/entry-common.h
> index a8f9315b9eae..76410964585f 100644
> --- a/arch/x86/include/asm/entry-common.h
> +++ b/arch/x86/include/asm/entry-common.h
> @@ -18,8 +18,15 @@ static __always_inline void arch_check_user_regs(struct pt_regs *regs)
>                  * state, not the interrupt state as imagined by Xen.
>                  */
>                 unsigned long flags = native_save_fl();
> -               WARN_ON_ONCE(flags & (X86_EFLAGS_AC | X86_EFLAGS_DF |
> -                                     X86_EFLAGS_NT));
> +               unsigned long mask = X86_EFLAGS_DF | X86_EFLAGS_NT;
> +
> +               /*
> +                * For !SMAP hardware we patch out CLAC on entry.
> +                */
> +               if (boot_cpu_has(X86_FEATURE_SMAP))
> +                       mask |= X86_EFLAGS_AC;
> +
> +               WARN_ON_ONCE(flags & mask);
>
>                 /* We think we came from user mode. Make sure pt_regs agrees. */
>                 WARN_ON_ONCE(!user_mode(regs));

LGTM.

Acked-by: Andy Lutomirski <luto@kernel.org>

  reply	other threads:[~2020-08-22 22:00 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-03 17:02 [PATCH entry v2 0/6] x86/entry: Fixes and cleanups Andy Lutomirski
2020-07-03 17:02 ` [PATCH entry v2 1/6] x86/entry/compat: Clear RAX high bits on Xen PV SYSENTER Andy Lutomirski
2020-07-04 17:49   ` [tip: x86/urgent] " tip-bot2 for Andy Lutomirski
2020-07-03 17:02 ` [PATCH entry v2 2/6] x86/entry, selftests: Further improve user entry sanity checks Andy Lutomirski
2020-07-04 17:49   ` [tip: x86/urgent] " tip-bot2 for Andy Lutomirski
2020-08-20 10:23     ` peterz
2020-08-22 21:59       ` Andy Lutomirski [this message]
2020-07-03 17:02 ` [PATCH entry v2 3/6] x86/entry/xen: Route #DB correctly on Xen PV Andy Lutomirski
2020-07-04 17:49   ` [tip: x86/urgent] " tip-bot2 for Andy Lutomirski
2020-07-06  8:41   ` [PATCH entry v2 3/6] " Michal Kubecek
2020-07-06  8:57     ` Jürgen Groß
2020-07-06  9:32       ` Michal Kubecek
2020-07-03 17:02 ` [PATCH entry v2 4/6] x86/entry/32: Fix #MC and #DB wiring on x86_32 Andy Lutomirski
2020-07-04 17:49   ` [tip: x86/urgent] " tip-bot2 for Andy Lutomirski
2020-07-03 17:02 ` [PATCH entry v2 5/6] x86/ldt: Disable 16-bit segments on Xen PV Andy Lutomirski
2020-07-03 19:00   ` Andrew Cooper
2020-07-04 17:49   ` [tip: x86/urgent] " tip-bot2 for Andy Lutomirski
2020-07-03 17:02 ` [PATCH entry v2 6/6] x86/entry: Rename idtentry_enter/exit_cond_rcu() to idtentry_enter/exit() Andy Lutomirski
2020-07-07  8:23   ` [tip: x86/entry] " tip-bot2 for Andy Lutomirski
2020-07-03 17:31 ` [PATCH entry v2 0/6] x86/entry: Fixes and cleanups 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=CALCETrVFQuMcUgfDkREGFHSSF9UW5yy4UuNZSpjw1962eSvLyw@mail.gmail.com \
    --to=luto@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --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).