[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <tip-0795e94c2eacd888c88e2ad2321368b6b0fcb20a@git.kernel.org>
Date: Wed, 10 Jan 2018 10:12:49 -0800
From: tip-bot for Borislav Petkov <tipbot@...or.com>
To: linux-tip-commits@...r.kernel.org
Cc: thomas.lendacky@....com, gregkh@...ux-foundation.org,
ak@...ux.intel.com, jikos@...nel.org, tim.c.chen@...ux.intel.com,
mingo@...nel.org, dave.hansen@...el.com,
torvalds@...ux-foundation.org, peterz@...radead.org,
dwmw2@...radead.org, luto@...nel.org, pjt@...gle.com, bp@...e.de,
tglx@...utronix.de, hpa@...or.com, linux-kernel@...r.kernel.org,
andi@...stfloor.org
Subject: [tip:x86/pti] x86/alternatives: Fix optimize_nops() checking
Commit-ID: 0795e94c2eacd888c88e2ad2321368b6b0fcb20a
Gitweb: https://git.kernel.org/tip/0795e94c2eacd888c88e2ad2321368b6b0fcb20a
Author: Borislav Petkov <bp@...e.de>
AuthorDate: Wed, 10 Jan 2018 12:28:16 +0100
Committer: Thomas Gleixner <tglx@...utronix.de>
CommitDate: Wed, 10 Jan 2018 19:09:08 +0100
x86/alternatives: Fix optimize_nops() checking
The alternatives code checks only the first byte whether it is a NOP, but
with NOPs in front of the payload and having actual instructions after it
breaks the "optimized' test.
Make sure to scan all bytes before deciding to optimize the NOPs in there.
Reported-by: David Woodhouse <dwmw2@...radead.org>
Signed-off-by: Borislav Petkov <bp@...e.de>
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
Cc: Tom Lendacky <thomas.lendacky@....com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Tim Chen <tim.c.chen@...ux.intel.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Jiri Kosina <jikos@...nel.org>
Cc: Dave Hansen <dave.hansen@...el.com>
Cc: Andi Kleen <andi@...stfloor.org>
Cc: Andrew Lutomirski <luto@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@...ux-foundation.org>
Cc: Paul Turner <pjt@...gle.com>
Link: https://lkml.kernel.org/r/20180110112815.mgciyf5acwacphkq@pd.tnic
---
arch/x86/kernel/alternative.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
index 3344d33..e0b97e4 100644
--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -344,9 +344,12 @@ done:
static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 *instr)
{
unsigned long flags;
+ int i;
- if (instr[0] != 0x90)
- return;
+ for (i = 0; i < a->padlen; i++) {
+ if (instr[i] != 0x90)
+ return;
+ }
local_irq_save(flags);
add_nops(instr + (a->instrlen - a->padlen), a->padlen);
Powered by blists - more mailing lists