Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp1345006rdb; Fri, 1 Dec 2023 13:44:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEEoJ1jyUTE4iV62MYdiF77qso9T3Bb2TTdioSltUziD9ZQfOXqreABD9ImbNIwDwTT08vm X-Received: by 2002:a05:6870:810:b0:1fb:75b:2fd0 with SMTP id fw16-20020a056870081000b001fb075b2fd0mr219028oab.103.1701467058432; Fri, 01 Dec 2023 13:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701467058; cv=none; d=google.com; s=arc-20160816; b=VUJL4u8+vr3XvEMwZoqODMQZerIr2LvxokW/kdUTcFN/+T3kNCqYMCuqXKtPfZGaix duPV2QJ9P+pB/ictJ4hxxTznV1Hfrp8xP7F/5++UYO97JJssfkplneiw249sZRF3CbK0 N/GbFMTgjl2lUPyNLZUNvG2WjAV0WpA7hFYKRX6/GORqlNPVUMICVNvRGU4uO9tk8EmU IgXOJ/mUevjHnrfn5fB8HMvBnld/G7peIzr1ou6gn2g39eSA6Y1e+C3XppXObct2N4yu IlwC+RxlLbaEqHHCzRYm04GtZ5YF0aRAHU3tgH/+bAldQUs50+EEoCQWdiRkWRgoIIpJ fZYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Y1vh3xJFQZtZyc8YcpkP/oT7gc6PDcdYeEQaMV62r4Y=; fh=XMwcZodbSH0Yn+14g58ALYoOc1ksms3ev818bY9r1qE=; b=DM6jIIcez/iEhyhe+Blxnc99Pb5YvXwad7gY9kgAWGW2gjIA7tQortwqHcuFlo5Lxl L9KFjbtRozIb5GL+5eMIs8tPA8Yl/ttQbDGcDxpewofOgzIyP+QwSTiX2mpJfs2+B+LA BOfHayXsYAmINObfXHESVUQkXANOJeAtTabccY7BUq9F+AWY5UWRH/43QAi3LanfmlhC x0rK1Pwm1l6CYdsp6Bid7lm+/q/L0V2/nhe/NC3MTC6T3cq0nrUF+z+eemZW0buvTBG9 tLA302HwjgkWCBt5UP41PaIH9xbRwwaS7Q2592aADuMWX5LIF6Vi5UMiAZIh8erfZy/H 4Dpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SrE6sgFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id h128-20020a636c86000000b005789f552066si4151558pgc.335.2023.12.01.13.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 13:44:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=SrE6sgFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id C9FC2837BE7F; Fri, 1 Dec 2023 13:44:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229560AbjLAVoC (ORCPT + 99 others); Fri, 1 Dec 2023 16:44:02 -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> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Fri, 01 Dec 2023 13:44:15 -0800 (PST) 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 >