From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35E6C33F378 for ; Wed, 15 Apr 2026 10:48:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776250091; cv=none; b=Efvt9PZF63CPX60Jy7bLNr8kwutfXQIVInguhRp9nDCa1Axr3a1oLo9lx/xn2Ow9cLZp3cSxKtIHdubo6M53JhuITpcZgnEz0EyJVY1sm0GMz4rsn5vmWxQI+8TaeMIDp3GA7s+9RxmlF59bDYHtf27NrqRjzkD06+m5WQ9nGgg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776250091; c=relaxed/simple; bh=Dvh9mQkEnQ4aXcsc1cq9pNgA6gBkZ+FQIxt8qYsS80c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nsq4CTSEUcBEux2+tFLhA8FnkxLYqxv89EbDWfvQrqWH9prjqbWRrrl8VIOMy6tgeOixG74LMteyzn+5dCdcjrgMUcK54BhCMY4WqJMpF0RIjAAqViPgfBPUWcQmcsAaTso/CYL+UINjsLDIHAMBLf8seGu84l6tYGBcukjhB18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=ZUht1HGf; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ZUht1HGf" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E2A94FD5; Wed, 15 Apr 2026 03:48:01 -0700 (PDT) Received: from arm.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 434E83F86F; Wed, 15 Apr 2026 03:48:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1776250087; bh=Dvh9mQkEnQ4aXcsc1cq9pNgA6gBkZ+FQIxt8qYsS80c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZUht1HGfT0Oh15Z86IdMgOiWq6TPFdFbWVSqTIreWLoCgvKYUnP9KYqSm4dWdhnhP b4b5ztSzCHeoLeCTOPU6U094QC8VKRd8x52lqhO+VvGZhvoGrcqL8CLLoLiKsqvFOB qUb1Bhp24iVVSxc1+TO3aOKQ+ERRtHfl3dFHMeGQ= Date: Wed, 15 Apr 2026 11:48:03 +0100 From: Catalin Marinas To: Wentao Guan 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 Message-ID: References: <20260413095459.2470584-1-guanwentao@uniontech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > --- > 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