Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp889864rdb; Fri, 1 Dec 2023 00:57:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFomDTh9xyAJ5emAq2dq3D5e+YapV8CDHJkdvPPFoY14kb6wunSlb01Sd7nVCiay7zUgM/q X-Received: by 2002:a05:6a21:6da3:b0:188:f3d:ea35 with SMTP id wl35-20020a056a216da300b001880f3dea35mr32028042pzb.50.1701421065515; Fri, 01 Dec 2023 00:57:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701421065; cv=none; d=google.com; s=arc-20160816; b=0dCil0PrBZSQ44comveEOroqw9bIxPT5evWxuEbTLOf6n18m8rmLeCoU3ZzUxGKXIU 7qnHkWkTSjRB7SajQ1dK0xB672AHTY898K0AEO9pxI0QJiJOlY+k7czOwa8fuLYJehNm jzEzW/idktrcMDvShQWq266C8nNm/+mBpSor6+Z3dqM9RC7HxAFl5JrfVVc6UfrW0gnM KztXCFeP+8gbb3jpG+FQ32p9RfevfTbRnKlcI6dFiBslTVUY9Tm94Ytczb9QFtP6nK9f OBInti05CIPiTMTmNtypI6vLjmsTEdlHrSyaMNaQ/hdbBc82VDH61Jv1BMhcw7cpgt/N JQGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=KEz57f4iqZ5wbUjNIKafkeeRwZy5R/glhsL5WersMuc=; fh=4hI3KqPAxd/MxKq9UeDHM1OHHZPw9LzVfOGk6ByITxk=; b=pYw1/dpzcmk1uE/QRG6gKyTl7Zm97hwTy4bRu2Qx00OqpQAM7C/0AHLgezgdWLjQRn Z95BHdaODYTKMfTj+S4+FA0Y6PLPGQ/7078CPIw9btC6CKQubT/dyJD55MFqUd3nsa3w dDmLlSt1uiZt3lPsmukfQgDh0dodX54wnzAIJhhAiWi7jsKSHAViGxrUV2iXsifYeRee bCbHqLPFAGuleaumIKLnQNS0/vslmKiQ3/r0nrKhkDkLVmffkucmRu2Hcy3N+LYW7UXN jFyr637Dag85WqFCev00sX2HLzBr4xDFB2lPyAJX5P5jE02GSTrZIaWVw0yu+NfG0gNd CwQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VmVGpAen; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id cm5-20020a17090afa0500b002864c435447si1944598pjb.126.2023.12.01.00.57.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 00:57:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=VmVGpAen; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5EF15805FD00; Fri, 1 Dec 2023 00:57:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229486AbjLAI50 (ORCPT + 99 others); Fri, 1 Dec 2023 03:57:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjLAI5Z (ORCPT ); Fri, 1 Dec 2023 03:57:25 -0500 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1094E84 for ; Fri, 1 Dec 2023 00:57:32 -0800 (PST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-40b427507b7so13989265e9.2 for ; Fri, 01 Dec 2023 00:57:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701421050; x=1702025850; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=KEz57f4iqZ5wbUjNIKafkeeRwZy5R/glhsL5WersMuc=; b=VmVGpAenl2ZnMeQH0YDZPhI4A5/3waD5jgiMJB7rl9re+V6QIFs2Td4C8XB94OiYti ho6Gc3cnRQqsW+5I2lxDU1RN8paq4QR7A5EtUZm/v1FF1v1B9IeNE2W9/fZJL0g7PCr+ iIfnh1qU8QYziyEFzrRGqtd3BPJQVDaLS/V0IXXvj3xa00AOur3cZJan17o/R+rf0+Y2 50M2pXWtU2Z5D0iVF36GzkmuVkMEPA1jFHNAotqJ1z5BIVUNN1e1EGGJWMxllnUpT+FE +IUROs+B0PmwIbDInKsbq6C7fTamjbaKgIZHQ9/9IfzTD+8TeEI/5LRSODdbpyqLn7a3 q6wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701421050; x=1702025850; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KEz57f4iqZ5wbUjNIKafkeeRwZy5R/glhsL5WersMuc=; b=SMpz2O6fkqA7xtCn7Rr8UJgnmpjKd6xSYyHb9csdEzHl5Mv1IrSGBHOt25ChvDmXrE pYmpQycaAUkQaeuMZ5ZnEzcSQ8/VGPcYvG7A4gx8OrQrGcAcZQEk6aKp7C2Bv/97hi6b mHLE8eU9URW3qz8bcVh8dmh/z00ONmASY7pl6dZLYVQCt7aF4sr8sdWOQqm1OvWXIK3e 2aJhXQHFh/AS6uD4UJ0fclaUQaeqOTMFJMol2q4Wy/ytgd9V5ms2gwH7z/SKjyre19/5 fQxQERnfMezjodUELAxpElRBL6m12Fgne6kWZAMO2bpMUBP56zBH4tOwzvsv+WyhpDG3 polA== X-Gm-Message-State: AOJu0YybeTSDM/yA+JRsV5ymLolCf2XobJnR0ZM69gN8YZRO4cDjMl4O 2TYme6yWloGrsPMAuDtTWqY= X-Received: by 2002:a05:600c:a2a2:b0:40b:5e59:b7d9 with SMTP id hu34-20020a05600ca2a200b0040b5e59b7d9mr245294wmb.182.1701421050257; Fri, 01 Dec 2023 00:57:30 -0800 (PST) Received: from localhost.si ([193.77.86.250]) by smtp.gmail.com with ESMTPSA id je18-20020a05600c1f9200b003feea62440bsm4753894wmb.43.2023.12.01.00.57.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 00:57:30 -0800 (PST) From: Uros Bizjak To: x86@kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Nathan Chancellor , Ingo Molnar Subject: [PATCH] x86/callthunks: Correct calculation of dest address in is_callthunk() Date: Fri, 1 Dec 2023 09:57:27 +0100 Message-Id: <20231201085727.3647051-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 01 Dec 2023 00:57:41 -0800 (PST) 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 --- 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