All of lore.kernel.org
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Wentao Guan <guanwentao@uniontech.com>
Cc: linux-arm-kernel@lists.infradead.org, will@kernel.org,
	hello@peppergray.xyz, linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] arm64/scs: Fix potential sign extension issue of advance_loc4
Date: Wed, 15 Apr 2026 11:48:03 +0100	[thread overview]
Message-ID: <ad9s4xdtsQ1As2Q_@arm.com> (raw)
In-Reply-To: <20260413095459.2470584-1-guanwentao@uniontech.com>

On Mon, Apr 13, 2026 at 05:54:59PM +0800, Wentao Guan wrote:
> The expression (*opcode++ << 24) and exp * code_alignment_factor
> may overflow signed int and becomes negative.
> 
> Fix this by casting each byte to u64 before shifting. Also fix
> the misaligned break statement while we are here.
> 
> Example of the result can be seen here:
> Link: https://godbolt.org/z/zhY8d3595
> 
> It maybe not a real problem, but could be a issue in future.
> 
> Fixes: d499e9627d70 ("arm64/scs: Fix handling of advance_loc4")
> Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
> ---
>  arch/arm64/kernel/pi/patch-scs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/kernel/pi/patch-scs.c b/arch/arm64/kernel/pi/patch-scs.c
> index dac568e4a54f2..3944ad899021c 100644
> --- a/arch/arm64/kernel/pi/patch-scs.c
> +++ b/arch/arm64/kernel/pi/patch-scs.c
> @@ -196,9 +196,9 @@ static int scs_handle_fde_frame(const struct eh_frame *frame,
>  			loc += *opcode++ * code_alignment_factor;
>  			loc += (*opcode++ << 8) * code_alignment_factor;
>  			loc += (*opcode++ << 16) * code_alignment_factor;
> -			loc += (*opcode++ << 24) * code_alignment_factor;
> +			loc += ((u64)*opcode++ << 24) * code_alignment_factor;
>  			size -= 4;
> -		break;
> +			break;

The fix makes sense. I'll queue it at -rc1.

Thanks.

-- 
Catalin


  reply	other threads:[~2026-04-15 10:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-13  9:54 [PATCH RFC] arm64/scs: Fix potential sign extension issue of advance_loc4 Wentao Guan
2026-04-15 10:48 ` Catalin Marinas [this message]
2026-04-27 13:39 ` Catalin Marinas

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=ad9s4xdtsQ1As2Q_@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=guanwentao@uniontech.com \
    --cc=hello@peppergray.xyz \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will@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.