x86/alternatives: Fix optimize_nops() checking
authorBorislav Petkov <[email protected]>
Wed, 10 Jan 2018 11:28:16 +0000 (12:28 +0100)
committerThomas Gleixner <[email protected]>
Wed, 10 Jan 2018 18:36:22 +0000 (19:36 +0100)
commit612e8e9350fd19cae6900cf36ea0c6892d1a0dca
tree8f5c3f1f6ae856deb97fae715cdb0c692a900d63
parent9ecccfaa7cb5249bd31bdceb93fcf5bedb8a24d8
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 <[email protected]>
Signed-off-by: Borislav Petkov <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: Tom Lendacky <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Tim Chen <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Jiri Kosina <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: Andrew Lutomirski <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Paul Turner <[email protected]>
Link: https://lkml.kernel.org/r/[email protected]
arch/x86/kernel/alternative.c