From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F12CC4167B for ; Fri, 1 Dec 2023 21:44:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379695AbjLAVoD (ORCPT ); Fri, 1 Dec 2023 16:44:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229456AbjLAVoB (ORCPT ); Fri, 1 Dec 2023 16:44:01 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00F6DE6 for ; Fri, 1 Dec 2023 13:44:07 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ADDDC433C9; Fri, 1 Dec 2023 21:44:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701467047; bh=Gt2exZhN0pfBhamoCKIzysIgj2FlXmSneCvHWmAiG1o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=SrE6sgFs70knxhrz67wYrNEqcgFC+AdktpAWBbze6mUqHNG+++qLum+0DA4kxYsm2 QmThJR8YPgLxB0hP495k/fLvImeUyLdmCxoWF7yuHgT1pBQlYFD/dZdLDwes6649GM l2ryaKPwodXfb+T8gCq2DlE05hL8rnZDq56WU/XEGou92PWt/lDqLint27GmlYkDiC G1UJIhqDIVQEjFApUp79dy7S6pA2RvWgReNLaEGxR6+tLqRJKeJhFQBpPeLPFfuf0N OB7PSF0PUVNKjTLQ39XfBsIdeumJqQ1/qlTmkhWq5v9XbFtwXEcWTMlpQ9GdvUDqFk I6YRjpPQniUWA== Date: Fri, 1 Dec 2023 14:44:05 -0700 From: Nathan Chancellor To: Uros Bizjak Cc: x86@kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, Ingo Molnar Subject: Re: [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk() Message-ID: <20231201214405.GA1533860@dev-arch.thelio-3990X> References: <20231201085727.3647051-1-ubizjak@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231201085727.3647051-1-ubizjak@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Closes: https://lore.kernel.org/lkml/20231201035457.GA321497@dev-arch.thelio-3990X/ > Cc: Ingo Molnar > Signed-off-by: Uros Bizjak 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 > --- > 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 >