From patchwork Sat Oct 22 07:26:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7544 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1105887wrr; Sat, 22 Oct 2022 01:36:26 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/guY7AqHfuF+h9bGz6/i3fj4zFfQ4FWCX2GWVRw6/uzFyscRsITN3BcD+cyUYvZsYu4lz X-Received: by 2002:a17:90b:4f8a:b0:212:cf2f:ea7e with SMTP id qe10-20020a17090b4f8a00b00212cf2fea7emr8389038pjb.66.1666427786430; Sat, 22 Oct 2022 01:36:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427786; cv=none; d=google.com; s=arc-20160816; b=NKVxd7h9cRYZePmt5ZbElnjL8+O4+oryI+YMqvDaFwnXJd4vSOYRmE4oA5w5/z9Cqb i/G1wBCbsteNLBVux2ZGHsKGaMrg2lEuCNj6wvsHILK2oBrYKa2sPOqLQ1sEQXhTqE+f BBhh4hEe2CUZJ/WR65LxGcFcbbVjipvsZW1Eun+TB9eP+/oz3GawrPBHjFLf1m1hdnAt jm5tDK8NhKwVfPlKGIr2CO1M5dDyDHbK0+6Y4IyL3ieUOFg3xz5XvX6nBlfFXULFYazT jI9UhsC2+ykAiWmQgt366ifM5ss5vtHASLRcIvhvAnY1X52pu3qeQdvEIT6qY/pr9JbP b3kw== 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=QfiNaxmAe/15z3rxYrCnYiB69UWKjtQas915u40sX05vsGHd0wlhza3TvN1xE2wPv+ xk5qLl7PPIUPZzns2CsOEdEyAEWtS00hM9Fdb/1W3Fcl/ktqhOM23BSUisqVENEfHN2F W1YZus5Y7RhKTypycXaymMIndiJKUF6bpZnsc4S9SJFzHP+oyHbeVYeARGKZJLFKpfmY d8dQO8ZOKfSuQXxHzvoWNcyPrXkNEq0pii6v23hC4EbheDtqXeWKl8KgN7OY1trHK+y6 zStW0jV25Cak4nQid1mN7hIGVwiQZbdPIpz/Sz/LgSwNNx6MgQgwc1OaeDx0mBISeDk3 pBIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0BqF1OTP; 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 k138-20020a628490000000b00562dda10caesi26537225pfd.245.2022.10.22.01.36.11; Sat, 22 Oct 2022 01:36:26 -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=0BqF1OTP; 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 S230017AbiJVI1P (ORCPT + 99 others); Sat, 22 Oct 2022 04:27:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233586AbiJVIZh (ORCPT ); Sat, 22 Oct 2022 04:25:37 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 462CB1826FE; Sat, 22 Oct 2022 01:00:35 -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 ams.source.kernel.org (Postfix) with ESMTPS id F0810B82E1E; Sat, 22 Oct 2022 07:58:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48964C433D6; Sat, 22 Oct 2022 07:58:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425497; bh=V158gqfaGOuKvv7mls5uKxEIcANh4s5FzQov9SkR/sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0BqF1OTPs7yz7ovNxRLXEaQ3tBY9u3yi6UC33oyXkKLxn8r8JWG6o43Mm/iJygcW6 79vvRXhtDCAPB8Hgb77iKHIDjp5LZNAlNkUhh5beUzpMvk7qdu47RDLLhU/B20SZM5 dJPtJBiBVWoWw88BexnFnCeF7B8TJEd4ojpeZvDc= 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 5.19 519/717] crypto: inside-secure - Change swab to swab32 Date: Sat, 22 Oct 2022 09:26:38 +0200 Message-Id: <20221022072521.251498785@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376182509448618?= X-GMAIL-MSGID: =?utf-8?q?1747376182509448618?= 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);