All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk()
@ 2023-12-01  8:57 Uros Bizjak
  2023-12-01 21:44 ` Nathan Chancellor
  2023-12-02 13:08 ` [tip: x86/percpu] " tip-bot2 for Uros Bizjak
  0 siblings, 2 replies; 3+ messages in thread
From: Uros Bizjak @ 2023-12-01  8:57 UTC (permalink / raw)
  To: x86, llvm, linux-kernel; +Cc: Uros Bizjak, Nathan Chancellor, Ingo Molnar

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>
Closes: https://lore.kernel.org/lkml/20231201035457.GA321497@dev-arch.thelio-3990X/
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
---
 arch/x86/kernel/callthunks.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
index f5507c95e7be..c561dd481eb9 100644
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -306,7 +306,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,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk()
  2023-12-01  8:57 [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk() Uros Bizjak
@ 2023-12-01 21:44 ` Nathan Chancellor
  2023-12-02 13:08 ` [tip: x86/percpu] " tip-bot2 for Uros Bizjak
  1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-12-01 21:44 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: x86, llvm, linux-kernel, Ingo Molnar

On Fri, Dec 01, 2023 at 09:57:27AM +0100, Uros Bizjak wrote:
> 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>
> Closes: https://lore.kernel.org/lkml/20231201035457.GA321497@dev-arch.thelio-3990X/
> Cc: Ingo Molnar <mingo@kernel.org>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>

This obviously clears up the warning and all my machines booted
(although I don't think any of them actually exercise this code path?):

Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  arch/x86/kernel/callthunks.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
> index f5507c95e7be..c561dd481eb9 100644
> --- a/arch/x86/kernel/callthunks.c
> +++ b/arch/x86/kernel/callthunks.c
> @@ -306,7 +306,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,
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: x86/percpu] x86/callthunks: Correct calculation of dest address in is_callthunk()
  2023-12-01  8:57 [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk() Uros Bizjak
  2023-12-01 21:44 ` Nathan Chancellor
@ 2023-12-02 13:08 ` tip-bot2 for Uros Bizjak
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Uros Bizjak @ 2023-12-02 13:08 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Nathan Chancellor, Uros Bizjak, Ingo Molnar, x86, linux-kernel

The following commit has been merged into the x86/percpu branch of tip:

Commit-ID:     fc50065325f8b88d6986f089ae103b5db858ab96
Gitweb:        https://git.kernel.org/tip/fc50065325f8b88d6986f089ae103b5db858ab96
Author:        Uros Bizjak <ubizjak@gmail.com>
AuthorDate:    Fri, 01 Dec 2023 09:57:27 +01:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Sat, 02 Dec 2023 10:51:28 +01:00

x86/callthunks: Correct calculation of dest address in is_callthunk()

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/callthunks.c b/arch/x86/kernel/callthunks.c
index f56fa30..2324c7f 100644
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -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,

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-02 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-01  8:57 [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk() Uros Bizjak
2023-12-01 21:44 ` Nathan Chancellor
2023-12-02 13:08 ` [tip: x86/percpu] " tip-bot2 for Uros Bizjak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.