Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp287994rwb; Fri, 18 Nov 2022 01:12:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6N5NmMwCVOhndHZPUGWIZgpZAEfdK1Z88tw1iDxuU2Tg1U+6ROTxEFHyWVrbkFXGsgrUTU X-Received: by 2002:a05:6402:10c4:b0:467:7827:232 with SMTP id p4-20020a05640210c400b0046778270232mr5576277edu.268.1668762752439; Fri, 18 Nov 2022 01:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668762752; cv=none; d=google.com; s=arc-20160816; b=OjalKluprmpZSBL1Ax32xEt+L9YQr98HUse3yqYAVow2NV+kkTzw91UADVpJVow7e6 5ajKJKy6UE607QkCrVq+glLTFyIuOD2mDQLSUl9U4lA+iZMc/0KuYUtYSNKZB4Dq0kNm BqNQxshbxzY2AYZ9qsnLqZxX4/qpNHkzPk/qi/YJZLe8qq8kL3vG35I6RsF39wq7nvxO 3L96POk0E89AO+yKyezlcignC0EwaZadGTdj5Qq/jN21+TyxX8X7wdxTAh0tsQqZ7Mt4 QwLUJIz+SJUFt4EZlRjZeRe2XJinDo756ktubuhmWsJtO+Sm9h0Q+aFVF5xGh2xjKupY uFpg== 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=BgFRtD5J0QQA1Gn/N6e8UtsqLYvIKXCqXGt701O/5cg=; b=dU7AYPgFAHfRbe69h0vXcxnrAxLjb9ZlkDvdIIomYIrYKg0bFY9t0bea+4qV9r4mdu iyIHXPnmOOJHO1uacMTA28GTrM+Vm0ZJPUNrHeUOHGQPwPoUQf1SYCRzpcqPPtdH+vQ4 sklaUQb/6LO1LJ4jOfMCJc5hwawlqDevPLskd3OKAxbetrCyn0xFRij3jWIIoI5yhnCO M7/cPM5py8oPCppHaOH6Wh/Ub/JoUINAMpqDvSWN4arEnH4z5v3uxWvrruk7/+QfVQAc 8PwiDmpp2ID/YzxNJG74Fk9jfN9gVYGSIzgjM5uS6gKetyfeApGLBjmnG5X5i97urgMq 6mZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Zf8+T9vZ; 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 ne38-20020a1709077ba600b00788361f96a2si3118700ejc.776.2022.11.18.01.12.05; Fri, 18 Nov 2022 01:12:32 -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=Zf8+T9vZ; 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 S241530AbiKRJEV (ORCPT + 99 others); Fri, 18 Nov 2022 04:04:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241704AbiKRJEM (ORCPT ); Fri, 18 Nov 2022 04:04:12 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEF7382BC9 for ; Fri, 18 Nov 2022 01:04:09 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1BB78623BB for ; Fri, 18 Nov 2022 09:04:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62593C433D7; Fri, 18 Nov 2022 09:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668762248; bh=izas7t+6oGMs9+g/37vH55gFtFtlIMabHc0IYfz658Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zf8+T9vZhJ4QB3orc2MRN4ra0Ac9rGJfEPJ53UqrkXAPvoo44QU3Vu7eUy/ch24I7 AHTqR9zvBWC12+JTY29n6NBcr/crrWNjbKxqztDHjwYgRxaSX0vApyVLgdTFYBvK9K u8ZUFQFlt3bCQZaUO3BbD1owS0hPOpx6hlKuuCg70BSYk4ueI5RtPQGXwn2RVzFox8 GzUw7yvAArNuDMULWjziqgd/Fppz6Z06e9j76DD8YaV215kQb8yzTnR2Kut3QniMxe nQ9MSxd0vciqlDwuWJoAHQnwgwQ5BxxvLWpg/DGL60PQ8I3KfUp8J0Ge6kvK9xzTsg 6iLV/zxHtLD2w== From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org, Sami Tolvanen Subject: [PATCH 04/11] crypto: x86/sha1 - fix possible crash with CFI enabled Date: Fri, 18 Nov 2022 01:02:13 -0800 Message-Id: <20221118090220.398819-5-ebiggers@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221118090220.398819-1-ebiggers@kernel.org> References: <20221118090220.398819-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. These functions need to use SYM_TYPED_FUNC_START instead of SYM_FUNC_START to cause 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: 3c516f89e17e ("x86: Add support for CONFIG_CFI_CLANG") 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