public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Thorlton <alex.thorlton@oracle.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Alex Thorlton <alex.thorlton@oracle.com>,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Kefeng Wang <wangkefeng.wang@huawei.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] x86/paravirt: Apply paravirt instructions in consistent order during boot/module load
Date: Mon, 7 Mar 2022 13:02:17 -0600	[thread overview]
Message-ID: <YiZWudMX7Yt3QSs2@linux-qygv> (raw)
In-Reply-To: <20220307184505.pvwzjujlqoyrpk44@treble>

On Mon, Mar 07, 2022 at 10:45:05AM -0800, Josh Poimboeuf wrote:
> On Mon, Mar 07, 2022 at 12:03:38PM -0600, Alex Thorlton wrote:
> > Commit 4e6292114c74 ("x86/paravirt: Add new features for paravirt
> > patching") changed the order in which altinstructions and paravirt
> > instructions are patched at boot time.  However, no analogous change was
> > made in module_finalize, where we apply altinstructions and
> > parainstructions during module load.
> > 
> > As a result, any code that generates "stacked up" altinstructions and
> > parainstructions (i.e. local_irq_save/restore) will produce different
> > results when used in built-in kernel code vs. kernel modules.  This also
> > makes it possible to inadvertently replace altinstructions in the booted
> > kernel with their parainstruction counterparts when using
> > livepatch/kpatch.
> > 
> > To fix this, re-order the processing in module_finalize, so that we do
> > things in this order:
> > 
> >  1. apply_paravirt
> >  2. apply_retpolines
> >  3. apply_alternatives
> >  4. alternatives_smp_module_add
> > 
> > This is the same ordering that is used at boot time in
> > alternative_instructions.
> > 
> > Fixes: 4e6292114c74 ("x86/paravirt: Add new features for paravirt patching")
> > Signed-off-by: Alex Thorlton <alex.thorlton@oracle.com>
> > Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> 
> Peter previously posted a fix, buried in his IBT series:
> 
>   https://urldefense.com/v3/__https://lkml.kernel.org/r/20220303112825.068773913@infradead.org__;!!ACWV5N9M2RV99hQ!YARvXhahbleGAt689pqTXJU7ko-rePIjzrbuGmemJXgFRViFZ8FDfOy7mHZQ7CPaG6Y$ 
> 
> It should probably go ahead and be merged now...

Ahh, yep - hadn't seen that one yet!  In any case, I'm glad this is on
other folk's radar.

Thanks for letting me know, Josh!

- Alex

      reply	other threads:[~2022-03-07 19:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-07 18:03 [PATCH] x86/paravirt: Apply paravirt instructions in consistent order during boot/module load Alex Thorlton
2022-03-07 18:45 ` Josh Poimboeuf
2022-03-07 19:02   ` Alex Thorlton [this message]

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=YiZWudMX7Yt3QSs2@linux-qygv \
    --to=alex.thorlton@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=wangkefeng.wang@huawei.com \
    --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