Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp5257267rwj; Tue, 20 Dec 2022 23:33:00 -0800 (PST) X-Google-Smtp-Source: AMrXdXtN0I7j5enenucQ2vTFXFAcJKfNX5IQmxmIYN7f6nb+JYog699Nwn+fjuwQ7EEQy4Avpey1 X-Received: by 2002:a17:902:710f:b0:190:d69c:1418 with SMTP id a15-20020a170902710f00b00190d69c1418mr14861066pll.2.1671607980112; Tue, 20 Dec 2022 23:33:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671607980; cv=none; d=google.com; s=arc-20160816; b=Nnud8fZsOfNgfTvXMvqKiw0iCeVuomX+gw0uJbfdyjJqYQkvI/O9svMVgq7jQ6LOnK t8X0uaMAP7gbVrKdYaB3nFlbdaTpgZ3L65EFflrCjB6twDCNxG9all4ATQzAIDlAuTLt fpP+WQAJuXKvhIiEXKsm9aRUzZ4Jbys1ttujJ66roa2yoSWGM53I7zggpfDS/4R5uEUm 3YnfqtzuGWnCmTnjLMseQSV8NQNKFCX+TYY8mupbUEzgEcrlT7yQB41E5gtj65tLzm5j 1x3D/pjANwm37Cy8mKz+aur7C8WhAw1ssbM74f+53cTEtQ2ErHn5mtlY/peTrdH+RvOT 4ksQ== 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; bh=vSIh8I7lRe5TdtZp7uN6BXIkCQNU8Sa1wShzL/3VPnc=; b=kljTgqBElRv+DoDjfofbGfVkdaIJBneKQVIsgcLTM0Zv2bxbL1ZEdaHNEcccKmhkB0 o3zKkMbUr/DsSXeZ02wYdxlG/Gg+CG1frxAunF+f0CuMpL3BqsS/FsHjTw2ZzC0GlTRp 0asKFjsJywq+5M9t9N3SfFawhT50RgDSSRDedYaIjjKtuVJ38c70asJeGk/htbqrDlYO sT/Jj2aj17raEoEfP9Tb12VXzRQp9VfdEQzr+qkBBj+tWF+nPmGrlX9qgwWe4TsV5dSx 52fIf96TlMPIcqW/0TGP/5xqKMZrkqQccCCtrBBNXFEoe1fpkASJJxm1ASKD6kUeliLO 8f1A== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a170902f20300b00188ef2314acsi14488164plc.527.2022.12.20.23.32.45; Tue, 20 Dec 2022 23:33:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229491AbiLUHck (ORCPT + 99 others); Wed, 21 Dec 2022 02:32:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231712AbiLUHci (ORCPT ); Wed, 21 Dec 2022 02:32:38 -0500 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDD7E380; Tue, 20 Dec 2022 23:32:36 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045192;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0VXoePt9_1671607952; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0VXoePt9_1671607952) by smtp.aliyun-inc.com; Wed, 21 Dec 2022 15:32:33 +0800 From: Tianjia Zhang To: Herbert Xu , "David S. Miller" , Catalin Marinas , Will Deacon , Eric Biggers , linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Tianjia Zhang Subject: [PATCH] crypto: arm64/sm4 - fix possible crash with CFI enabled Date: Wed, 21 Dec 2022 15:32:32 +0800 Message-Id: <20221221073232.15110-1-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 The SM4 CCM/GCM assembly functions for encryption and decryption is called via indirect function calls. Therefore they need to use SYM_TYPED_FUNC_START instead of SYM_FUNC_START to cause its type hash 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 call). Fixes: 67fa3a7fdf80 ("crypto: arm64/sm4 - add CE implementation for CCM mode") Fixes: ae1b83c7d572 ("crypto: arm64/sm4 - add CE implementation for GCM mode") Signed-off-by: Tianjia Zhang --- arch/arm64/crypto/sm4-ce-ccm-core.S | 5 +++-- arch/arm64/crypto/sm4-ce-gcm-core.S | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/crypto/sm4-ce-ccm-core.S b/arch/arm64/crypto/sm4-ce-ccm-core.S index 028207c4afd0..fa85856f33ce 100644 --- a/arch/arm64/crypto/sm4-ce-ccm-core.S +++ b/arch/arm64/crypto/sm4-ce-ccm-core.S @@ -8,6 +8,7 @@ */ #include +#include #include #include "sm4-ce-asm.h" @@ -104,7 +105,7 @@ SYM_FUNC_START(sm4_ce_ccm_final) SYM_FUNC_END(sm4_ce_ccm_final) .align 3 -SYM_FUNC_START(sm4_ce_ccm_enc) +SYM_TYPED_FUNC_START(sm4_ce_ccm_enc) /* input: * x0: round key array, CTX * x1: dst @@ -216,7 +217,7 @@ SYM_FUNC_START(sm4_ce_ccm_enc) SYM_FUNC_END(sm4_ce_ccm_enc) .align 3 -SYM_FUNC_START(sm4_ce_ccm_dec) +SYM_TYPED_FUNC_START(sm4_ce_ccm_dec) /* input: * x0: round key array, CTX * x1: dst diff --git a/arch/arm64/crypto/sm4-ce-gcm-core.S b/arch/arm64/crypto/sm4-ce-gcm-core.S index 7aa3ec18a289..347f25d75727 100644 --- a/arch/arm64/crypto/sm4-ce-gcm-core.S +++ b/arch/arm64/crypto/sm4-ce-gcm-core.S @@ -9,6 +9,7 @@ */ #include +#include #include #include "sm4-ce-asm.h" @@ -370,7 +371,7 @@ SYM_FUNC_START(pmull_ghash_update) SYM_FUNC_END(pmull_ghash_update) .align 3 -SYM_FUNC_START(sm4_ce_pmull_gcm_enc) +SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_enc) /* input: * x0: round key array, CTX * x1: dst @@ -581,7 +582,7 @@ SYM_FUNC_END(sm4_ce_pmull_gcm_enc) #define RH3 v20 .align 3 -SYM_FUNC_START(sm4_ce_pmull_gcm_dec) +SYM_TYPED_FUNC_START(sm4_ce_pmull_gcm_dec) /* input: * x0: round key array, CTX * x1: dst -- 2.24.3 (Apple Git-128)