x86/callthunks: Correct calculation of dest address in is_callthunk()
authorUros Bizjak <ubizjak@gmail.com>
Fri, 1 Dec 2023 08:57:27 +0000 (09:57 +0100)
committerIngo Molnar <mingo@kernel.org>
Sat, 2 Dec 2023 09:51:28 +0000 (10:51 +0100)
GCC didn't warn on the invalid use of relocation destination
pointer, so the calculated destination value was applied to
the uninitialized pointer location in error.

Fixes: 17bce3b2ae2d ("x86/callthunks: Handle %rip-relative relocations in call thunk template")
Reported-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Closes: https://lore.kernel.org/lkml/20231201035457.GA321497@dev-arch.thelio-3990X/
Link: https://lore.kernel.org/r/20231201085727.3647051-1-ubizjak@gmail.com
arch/x86/kernel/callthunks.c

index f56fa303d6431c8efa8f9eeadbbf5577fae684c5..2324c7f9a84131829ee01697041e8c0670174bf2 100644 (file)
@@ -312,7 +312,7 @@ static bool is_callthunk(void *addr)
        if (!thunks_initialized || skip_addr((void *)dest))
                return false;
 
-       *pad = dest - tmpl_size;
+       pad = (void *)(dest - tmpl_size);
 
        memcpy(insn_buff, skl_call_thunk_template, tmpl_size);
        apply_relocation(insn_buff, tmpl_size, pad,