aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2021-06-16 13:18:23 -0700
committerVasily Gorbik <gor@linux.ibm.com>2021-06-28 11:18:28 +0200
commitc74d3c182ab4a3db6c3c2a6c4b3c8b9a7f1feb1a (patch)
tree1286621ca4c6759d5d9ec1e78af01f72c474c228 /arch
parentvirtio/s390: get rid of open-coded kvm hypercall (diff)
downloadlinux-dev-c74d3c182ab4a3db6c3c2a6c4b3c8b9a7f1feb1a.tar.xz
linux-dev-c74d3c182ab4a3db6c3c2a6c4b3c8b9a7f1feb1a.zip
s390/speculation: Use statically initialized const for instructions
In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid confusing the checks when using a static const source. Move the static const array into a variable so the compiler can perform appropriate bounds checking. Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20210616201823.1245603-1-keescook@chromium.org Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/s390/kernel/nospec-branch.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/s390/kernel/nospec-branch.c b/arch/s390/kernel/nospec-branch.c
index 2c5c3756644b..250e4dbf653c 100644
--- a/arch/s390/kernel/nospec-branch.c
+++ b/arch/s390/kernel/nospec-branch.c
@@ -99,6 +99,7 @@ early_param("spectre_v2", spectre_v2_setup_early);
static void __init_or_module __nospec_revert(s32 *start, s32 *end)
{
enum { BRCL_EXPOLINE, BRASL_EXPOLINE } type;
+ static const u8 branch[] = { 0x47, 0x00, 0x07, 0x00 };
u8 *instr, *thunk, *br;
u8 insnbuf[6];
s32 *epo;
@@ -128,7 +129,7 @@ static void __init_or_module __nospec_revert(s32 *start, s32 *end)
if ((br[0] & 0xbf) != 0x07 || (br[1] & 0xf0) != 0xf0)
continue;
- memcpy(insnbuf + 2, (char[]) { 0x47, 0x00, 0x07, 0x00 }, 4);
+ memcpy(insnbuf + 2, branch, sizeof(branch));
switch (type) {
case BRCL_EXPOLINE:
insnbuf[0] = br[0];