From: Josh Boyer <jwboyer@fedoraproject.org>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Borislav Petkov <bp@alien8.de>,
"Richard W.M. Jones" <rjones@redhat.com>,
Chuck Ebbert <cebbert.lkml@gmail.com>,
"Linux-Kernel@Vger. Kernel. Org" <linux-kernel@vger.kernel.org>,
x86 <x86@kernel.org>, Ingo Molnar <mingo@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [BUG 4.2-rc8] Interrupt occurs while apply_alternatives() is patching the handler
Date: Thu, 3 Sep 2015 08:43:31 -0400 [thread overview]
Message-ID: <CA+5PVA5Y8Vdt2ueEw7JBEAsvvkZhXz0HbKbHRsM0gufVLQ_g_A@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1509031232340.15006@nanos>
On Thu, Sep 3, 2015 at 6:41 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Thu, 3 Sep 2015, Borislav Petkov wrote:
>> On Wed, Sep 02, 2015 at 11:11:55AM +0200, Thomas Gleixner wrote:
>> > static void __init_or_module add_nops(void *insns, unsigned int len)
>> > {
>> > + unsigned long flags;
>> > +
>> > + local_irq_save(flags);
>> > while (len > 0) {
>>
>> I guess you want to optimize the len==0 case to not disable interrupts
>> needlessly:
>>
>> if (!len)
>> return;
>>
>> local_irq_save(flags);
>> while (len > 0)
>> ...
>
> Nah. I rather put the local_irq_save into optimize_nops(). All other
> callers of add_nops() are operating on a buffer and use text_poke
> after that. Aside of that optimize_nops() is missing a sync_core().
>
> Updated patch below.
>
> Thanks,
>
> tglx
>
> ----------------->
> Subject: x86/alternatives: Make optimize_nops() interrupt safe and synced
> From: Thomas Gleixner <tglx@linutronix.de>
> Date: Thu, 03 Sep 2015 12:34:55 +0200
>
> optimize_nops() is buggy in two aspects:
>
> - It's not disabling interrupts across the modification
> - It's lacking a sync_core() call
>
> Fixes: 4fd4b6e5537c 'x86/alternatives: Use optimized NOPs for padding'
Possibly CC: stable since it fixes a commit in 4.1 and 4.2?
josh
> Reported-by: "Richard W.M. Jones" <rjones@redhat.com>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> ---
> arch/x86/kernel/alternative.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> Index: tip/arch/x86/kernel/alternative.c
> ===================================================================
> --- tip.orig/arch/x86/kernel/alternative.c
> +++ tip/arch/x86/kernel/alternative.c
> @@ -338,10 +338,15 @@ done:
>
> static void __init_or_module optimize_nops(struct alt_instr *a, u8 *instr)
> {
> + unsigned long flags;
> +
> if (instr[0] != 0x90)
> return;
>
> + local_irq_save(flags);
> add_nops(instr + (a->instrlen - a->padlen), a->padlen);
> + sync_core();
> + local_irq_restore(flags);
>
> DUMP_BYTES(instr, a->instrlen, "%p: [%d:%d) optimized NOPs: ",
> instr, a->instrlen - a->padlen, a->padlen);
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
next prev parent reply other threads:[~2015-09-03 12:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-31 2:37 [BUG 4.2-rc8] Interrupt occurs while apply_alternatives() is patching the handler Chuck Ebbert
2015-09-01 6:20 ` Richard W.M. Jones
2015-09-02 9:11 ` Thomas Gleixner
2015-09-02 19:05 ` Richard W.M. Jones
2015-09-03 7:53 ` Richard W.M. Jones
2015-09-03 8:50 ` Borislav Petkov
2015-09-03 10:41 ` Thomas Gleixner
2015-09-03 12:43 ` Josh Boyer [this message]
2015-09-03 13:01 ` Thomas Gleixner
2015-09-03 15:48 ` Richard W.M. Jones
2015-09-03 19:30 ` [tip:x86/urgent] x86/alternatives: Make optimize_nops() interrupt safe and synced tip-bot for Thomas Gleixner
2015-09-04 7:40 ` [BUG 4.2-rc8] Interrupt occurs while apply_alternatives() is patching the handler Richard W.M. Jones
2015-09-04 12:02 ` Borislav Petkov
2015-09-04 13:37 ` Thomas Gleixner
2015-09-05 15:25 ` Borislav Petkov
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=CA+5PVA5Y8Vdt2ueEw7JBEAsvvkZhXz0HbKbHRsM0gufVLQ_g_A@mail.gmail.com \
--to=jwboyer@fedoraproject.org \
--cc=bp@alien8.de \
--cc=cebbert.lkml@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rjones@redhat.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.