Go to file
Borislav Petkov 76474a9dd3 x86/alternative: Optimize single-byte NOPs at an arbitrary position
commit 2b31e8ed96b260ce2c22bd62ecbb9458399e3b62 upstream.

Up until now the assumption was that an alternative patching site would
have some instructions at the beginning and trailing single-byte NOPs
(0x90) padding. Therefore, the patching machinery would go and optimize
those single-byte NOPs into longer ones.

However, this assumption is broken on 32-bit when code like
hv_do_hypercall() in hyperv_init() would use the ratpoline speculation
killer CALL_NOSPEC. The 32-bit version of that macro would align certain
insns to 16 bytes, leading to the compiler issuing a one or more
single-byte NOPs, depending on the holes it needs to fill for alignment.

That would lead to the warning in optimize_nops() to fire:

  ------------[ cut here ]------------
  Not a NOP at 0xc27fb598
   WARNING: CPU: 0 PID: 0 at arch/x86/kernel/alternative.c:211 optimize_nops.isra.13

due to that function verifying whether all of the following bytes really
are single-byte NOPs.

Therefore, carve out the NOP padding into a separate function and call
it for each NOP range beginning with a single-byte NOP.

Fixes: 23c1ad538f4f ("x86/alternatives: Optimize optimize_nops()")
Reported-by: Richard Narron <richard@aaazen.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=213301
Link: https://lkml.kernel.org/r/20210601212125.17145-1-bp@alien8.de
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-25 11:26:19 +02:00
arch x86/alternative: Optimize single-byte NOPs at an arbitrary position 2022-07-25 11:26:19 +02:00
block
certs
crypto
Documentation
drivers serial: 8250: Fix PM usage_count for console handover 2022-07-21 21:20:19 +02:00
fs
include objtool: Combine UNWIND_HINT_RET_OFFSET and UNWIND_HINT_FUNC 2022-07-25 11:26:07 +02:00
init
ipc
kernel signal handling: don't use BUG_ON() for debugging 2022-07-21 21:20:18 +02:00
lib
LICENSES
mm
net net: tipc: fix possible refcount leak in tipc_sk_create() 2022-07-21 21:20:14 +02:00
samples
scripts
security ima: Fix potential memory leak in ima_init_crypto() 2022-07-21 21:20:11 +02:00
sound ASoC: madera: Fix event generation for rate controls 2022-07-21 21:20:16 +02:00
tools objtool: Support asm jump tables 2022-07-25 11:26:18 +02:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile Linux 5.10.132 2022-07-21 21:20:20 +02:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.