All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nathan Chancellor <nathan@kernel.org>
To: Uros Bizjak <ubizjak@gmail.com>
Cc: x86@kernel.org, llvm@lists.linux.dev,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk()
Date: Fri, 1 Dec 2023 14:44:05 -0700	[thread overview]
Message-ID: <20231201214405.GA1533860@dev-arch.thelio-3990X> (raw)
In-Reply-To: <20231201085727.3647051-1-ubizjak@gmail.com>

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
> 

  reply	other threads:[~2023-12-01 21:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-12-02 13:08 ` [tip: x86/percpu] " tip-bot2 for Uros Bizjak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231201214405.GA1533860@dev-arch.thelio-3990X \
    --to=nathan@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mingo@kernel.org \
    --cc=ubizjak@gmail.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.