From patchwork Wed Oct 19 08:32:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp336492wrs; Wed, 19 Oct 2022 06:47:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM78idwidD0dp11rKxVB/PHopPq7sjSm6E5b685Sz/MsDF+VDGHF/pP9FQR/eEg8fZAwuDAI X-Received: by 2002:a63:b4d:0:b0:454:d8b4:285 with SMTP id a13-20020a630b4d000000b00454d8b40285mr7406629pgl.410.1666187229826; Wed, 19 Oct 2022 06:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666187229; cv=none; d=google.com; s=arc-20160816; b=FH64gUelSYBVDxFFnrukBCrVtBiFywQrhjZ2FHWMg8K4XMZDJZw+14jpOLKgcMLKjj 7Niwf3kJG1/SOaj935AIThvJmjjSQB1YeJJd80ZU6koyHhkugnZCLqfo3WDeJRcO1hkV JCGBvVcobuIarkuu98SFCSC9SBu81UuxV/zzuoRr6zEKIcDsZLZGkDuO4ckSfMo0eSas c1wzOBPWIKIWvp4poCPzowVAa3BUyJ/snTzYzo1H0piHvICbKtcWjxKx7cUoGUpldWLl ep+MUrBKqTn+3ncgS/mwyufo2xcDT0B5zq3iTr9OUiyTOrPgYxegpo7D1cwOgJynbYVh ajvA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7x2n/RkekdGOKth6jNyMxgSl4XjLQSVzhxcKcZ4+GV8=; b=gEZhgu12hJhE+QIZ/2T/GiIL2JJdpi8GA8nrMJmyJRSGcFnP20AbG8+A3XNaH0H4Rd QCJzFeEZQnO/UWjI6d5pA9evOqS9cjtRofhNAlHDg/KfMqlSgfk/OgL7NyD6A4XSqAtu rfirORkH53zt5/OWGkFWX6XuZGfDfHZMhJHkAFvSdY8kRHVgGZOl1inmbLwfjVMn1E+C aqmMrxWI1pbExDg1Bxo0pp2Qah7l0U0sUSWrZf7aTUq2uQrmjofR7OqWmG3qVU05QmWZ dGT4dasRl12rZwusCWv3iTFNhIhS5PHusMEhefBPsSbvpc3AWiHWluWtUZR/iE0eZQHp D+1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cs2s97br; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c24-20020a637258000000b0041183daa0ffsi17200461pgn.761.2022.10.19.06.46.56; Wed, 19 Oct 2022 06:47:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=Cs2s97br; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233049AbiJSNqZ (ORCPT + 99 others); Wed, 19 Oct 2022 09:46:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233045AbiJSNp2 (ORCPT ); Wed, 19 Oct 2022 09:45:28 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 531DA3A154; Wed, 19 Oct 2022 06:31:53 -0700 (PDT) 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 sin.source.kernel.org (Postfix) with ESMTPS id 070DACE2182; Wed, 19 Oct 2022 09:06:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DB1DC433D6; Wed, 19 Oct 2022 09:06:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170409; bh=V158gqfaGOuKvv7mls5uKxEIcANh4s5FzQov9SkR/sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cs2s97brTX4g9/pdKdnupz9nPUvDqEXXS6R/XjtDnA36nTNNr48/R51zBymsegKGK VoWFLnOKQgy0HaOByK0UbRCPoDjDnwo6BWloNFPPBnocrkkytBObbrQTdTnrkOjE/p +lXpA7ATUAZzgZzrufoBwFDgL8YD0DhMN9pAQzaA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Harliman Liem , Antoine Tenart , Herbert Xu , Sasha Levin Subject: [PATCH 6.0 637/862] crypto: inside-secure - Change swab to swab32 Date: Wed, 19 Oct 2022 10:32:04 +0200 Message-Id: <20221019083318.078529484@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747123940931144894?= X-GMAIL-MSGID: =?utf-8?q?1747123940931144894?= From: Peter Harliman Liem [ Upstream commit 664593407e936b6438fbfaaf98876910fd31cf9a ] The use of swab() is causing failures in 64-bit arch, as it translates to __swab64() instead of the intended __swab32(). It eventually causes wrong results in xcbcmac & cmac algo. Fixes: 78cf1c8bfcb8 ("crypto: inside-secure - Move ipad/opad into safexcel_context") Signed-off-by: Peter Harliman Liem Acked-by: Antoine Tenart Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/inside-secure/safexcel_hash.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index bc60b5802256..2124416742f8 100644 --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -383,7 +383,7 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, u32 x; x = ipad[i] ^ ipad[i + 4]; - cache[i] ^= swab(x); + cache[i] ^= swab32(x); } } cache_len = AES_BLOCK_SIZE; @@ -821,7 +821,7 @@ static int safexcel_ahash_final(struct ahash_request *areq) u32 *result = (void *)areq->result; /* K3 */ - result[i] = swab(ctx->base.ipad.word[i + 4]); + result[i] = swab32(ctx->base.ipad.word[i + 4]); } areq->result[0] ^= 0x80; // 10- padding crypto_cipher_encrypt_one(ctx->kaes, areq->result, areq->result); @@ -2106,7 +2106,7 @@ static int safexcel_xcbcmac_setkey(struct crypto_ahash *tfm, const u8 *key, crypto_cipher_encrypt_one(ctx->kaes, (u8 *)key_tmp + AES_BLOCK_SIZE, "\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"); for (i = 0; i < 3 * AES_BLOCK_SIZE / sizeof(u32); i++) - ctx->base.ipad.word[i] = swab(key_tmp[i]); + ctx->base.ipad.word[i] = swab32(key_tmp[i]); crypto_cipher_clear_flags(ctx->kaes, CRYPTO_TFM_REQ_MASK); crypto_cipher_set_flags(ctx->kaes, crypto_ahash_get_flags(tfm) & @@ -2189,7 +2189,7 @@ static int safexcel_cmac_setkey(struct crypto_ahash *tfm, const u8 *key, return ret; for (i = 0; i < len / sizeof(u32); i++) - ctx->base.ipad.word[i + 8] = swab(aes.key_enc[i]); + ctx->base.ipad.word[i + 8] = swab32(aes.key_enc[i]); /* precompute the CMAC key material */ crypto_cipher_clear_flags(ctx->kaes, CRYPTO_TFM_REQ_MASK);