Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1045870rwb; Fri, 18 Nov 2022 11:53:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Gj+30SYNnXX7pUuuDpYllV5A3c5NR5Q1/XRUu52x3R4oe3bsCdIDpQMAUDll3ybD0OrbC X-Received: by 2002:a17:90a:f402:b0:218:7b33:60f with SMTP id ch2-20020a17090af40200b002187b33060fmr7469721pjb.79.1668801217784; Fri, 18 Nov 2022 11:53:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668801217; cv=none; d=google.com; s=arc-20160816; b=tHdE1PKBittozVxvlj038v0vhrIQy7Ryvbc4hSs0yLPifQkawkfAfTG3O7C+lxHmS/ F019c0Bi2cvfxo5RvLapAgOREjWj28DALgLNQs7OxPahIIgVdfwkvssHht2COkhaIwCp 070LhAAz46sED9FQ7AfEqEdlh5HkRrNPy71ZEUTL9gcV3xJ2euU0re+IZJtEm4Jb3wDH lcEZ8yO1y/iLEc4ClbsOX9zb7MfHLDyBjzVUdC+Wm7dz0etOhtSgz07w1kCRjWzN2aC9 DHa1yfxoYISnCZDkUbQI6jKH88QSQjrOrwnaKdxi1k43yV+boVRbn30egTpy5aEUz6h+ MTtw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p/l4m8j0B0ZojEzuj9TjmcHpzMuxv2ptckO39ynBk6Y=; b=HjMIA81kkTXYt11zwOXF8OQPz09z5D1/py2P0SBg7B/lMRrYekWu2FsERaE7k8AOQO YLnWRZ71DY9mI7ZcQ8ACEeDU5HTX5dCz6eQZ7r7HPtDzLon9YSQ2n3coWAcb9W8rLdfH Lo0OJQf5jbFpiyKtvQ1TW5AMZGK+r8Q00emZXbB4dl8QISOMr9B8a3h+ZkXxrvHOURGB WERitKDkTZ+qllEDaBPjd2UNP8y1scQKixwicaMlXYkG8hOhad0OcQklCmr+3jiXRwLs jP27El7StATMjZs2gEJ5WrMIEfj87srzCjAXBxwn0/GCS4w43V8TVle+qYeZ89YAmjBy 8beA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XVl2DMLV; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v17-20020a056a00149100b00563a0453c55si4693013pfu.268.2022.11.18.11.53.24; Fri, 18 Nov 2022 11:53:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XVl2DMLV; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235379AbiKRTqi (ORCPT + 99 others); Fri, 18 Nov 2022 14:46:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235521AbiKRTqa (ORCPT ); Fri, 18 Nov 2022 14:46:30 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5F4B8D4A8 for ; Fri, 18 Nov 2022 11:46:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6C1E9B82504 for ; Fri, 18 Nov 2022 19:46:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B446C43145; Fri, 18 Nov 2022 19:46:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668800785; bh=SJD1vbe3TbIhw+mwTcm5uBRYSsM1TzGphUBe1liqWrE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XVl2DMLVSs2HOx7cBmnsYJTM66kDDvXWPb6kNYxobQXvoNILZHP5QWdeeXp/xZX69 smMIgUE6p983K51FzNpAq24zTzSx+yVw1MMZc39NtTKCIdUkOb8MwdpH8QddBd+UCK aL7sM1o8a+PKgpxaxhSHsy/mIk8NQMdKyKLTVewufHX178cAhJ6ny04svwuucxOph/ uWYJncSByfA3ZtSqI5L5308goQSDGqKieLiK0bRgUj8RU+nUeRK5IyvyoOQE0IwGhx GOtXnFByE0zD+Qwmp24fzNwaP90B6VIDExux0LOgPgYRJq8KqBFsYtsg/TygwvGxA8 uOz10di6uwVgA== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, Sami Tolvanen , "Peter Zijlstra (Intel)" Subject: [PATCH v2 04/12] crypto: x86/sha1 - fix possible crash with CFI enabled Date: Fri, 18 Nov 2022 11:44:13 -0800 Message-Id: <20221118194421.160414-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118194421.160414-1-ebiggers@kernel.org> References: <20221118194421.160414-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Eric Biggers sha1_transform_ssse3(), sha1_transform_avx(), and sha1_ni_transform() (but not sha1_transform_avx2()) are called via indirect function calls. Therefore they need to use SYM_TYPED_FUNC_START instead of SYM_FUNC_START to cause their type hashes to be emitted when the kernel is built with CONFIG_CFI_CLANG=y. Otherwise, the code crashes with a CFI failure (if the compiler didn't happen to optimize out the indirect calls). Fixes: ccace936eec7 ("x86: Add types to indirectly called assembly functions") Acked-by: Peter Zijlstra (Intel) Reviewed-by: Sami Tolvanen Signed-off-by: Eric Biggers --- arch/x86/crypto/sha1_ni_asm.S | 3 ++- arch/x86/crypto/sha1_ssse3_asm.S | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/crypto/sha1_ni_asm.S b/arch/x86/crypto/sha1_ni_asm.S index 2f94ec0e763bf..3cae5a1bb3d6e 100644 --- a/arch/x86/crypto/sha1_ni_asm.S +++ b/arch/x86/crypto/sha1_ni_asm.S @@ -54,6 +54,7 @@ */ #include +#include #define DIGEST_PTR %rdi /* 1st arg */ #define DATA_PTR %rsi /* 2nd arg */ @@ -93,7 +94,7 @@ */ .text .align 32 -SYM_FUNC_START(sha1_ni_transform) +SYM_TYPED_FUNC_START(sha1_ni_transform) push %rbp mov %rsp, %rbp sub $FRAME_SIZE, %rsp diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S index 263f916362e02..f54988c80eb40 100644 --- a/arch/x86/crypto/sha1_ssse3_asm.S +++ b/arch/x86/crypto/sha1_ssse3_asm.S @@ -25,6 +25,7 @@ */ #include +#include #define CTX %rdi // arg1 #define BUF %rsi // arg2 @@ -67,7 +68,7 @@ * param: function's name */ .macro SHA1_VECTOR_ASM name - SYM_FUNC_START(\name) + SYM_TYPED_FUNC_START(\name) push %rbx push %r12 -- 2.38.1