From patchwork Mon Oct 24 11:31:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9136 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp457484wru; Mon, 24 Oct 2022 06:36:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6uuGFJPyD9w78SyHpNzZKchSgIclt6A7L/HGQ0WyUTgFIfB/MQzErWWYjf6M49rYM+7ywC X-Received: by 2002:a05:6402:1454:b0:461:9b5c:2fbc with SMTP id d20-20020a056402145400b004619b5c2fbcmr8465086edx.276.1666618566324; Mon, 24 Oct 2022 06:36:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618566; cv=none; d=google.com; s=arc-20160816; b=r+kMvwU6rIdxRK+GnGedHmttyBfFLKxXNNL2uW+T+xbgCmjnjSGJAk31hfPfHT2Cas 66pNdPvUoyK7Qx6dFeQj1oPalenfIEp4927hiDQ3xqp5z4WhGlXDkixU5Lx2yrPeRQGU f+J5wucvTZZdGaDYF/51QYzK+BL3eulUoEYb2qTjCZeGRVcfxOGqggJnOrMWa+Hv3ogO N03QftR/ulgBsdUcsqrE75Z9LCrGmaOeaGT9nGqY83drBElVWGmII+R+eSyMwp4cqUq0 NMNoKWRHssaffITDg4N6cs295MxQkR1R2ehgKqWlF3dbHPLKBBSKhq5ZONVQbDYK5yNZ 9dFw== 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=VN86ii+jcQXjsjJaXXsqLICrV2cLCqYX8NVHkANN/f8=; b=hcUX97w1GpGRcVwFk1NfkHEt/5cDEXn9gQwgAv3VB3pRw5kr2eIflwWYOZRThDbrBp 0emi60GQTVWzzaMm4l3l5wcVj53coYQ76MaWMXgwimmml4FJTBeTnPrYVBLnUVDSLUGq LKVPA6yCg3LcEeFb2bTtTC69BkJVfAmRtEUFgdkZTNoftKvBtvsKiQ2dHd3mDf11bpLB bqtp3ruoBh5yioOAI53dCDwc+YggYO5JZS25mFsdKYBA719aHaiDokj9Jb/uCxQuAaiS pm4J10ISSlrvnu+vbiZHKCanvCeWD8Q/v/U0khWGJ+nVCWTSfeDu5LVaB+FkJSQjlJMK L9qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Yur83e5C; 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 dp19-20020a170906c15300b0078c47b4478esi25972275ejc.106.2022.10.24.06.35.27; Mon, 24 Oct 2022 06:36:06 -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=Yur83e5C; 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 S231573AbiJXNXi (ORCPT + 99 others); Mon, 24 Oct 2022 09:23:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233288AbiJXNWx (ORCPT ); Mon, 24 Oct 2022 09:22:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C532399DE; Mon, 24 Oct 2022 05:30:03 -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 dfw.source.kernel.org (Postfix) with ESMTPS id AC1FC61014; Mon, 24 Oct 2022 12:28:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC4E9C433D6; Mon, 24 Oct 2022 12:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614484; bh=jr0TCbRMOB4Q39OQ40nhj67XsnQMm/VmhlxlIuIiE0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Yur83e5CbNXTzJ2vFBc74mbHYM10Z3IUfmOrOG3cvKItUSopviUf04iab0TSKlXeg XXvnKFOaTPA5kGPE21ECzx/pgg93y20gkQGHpD115B08xGPd8zqAN0LJkyQ8JbeXPd P5sM/0MVlY/eQq3A48bW59slht0Eyvu9+ey/vZhE= 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.10 278/390] crypto: inside-secure - Change swab to swab32 Date: Mon, 24 Oct 2022 13:31:15 +0200 Message-Id: <20221024113034.779350726@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747576229857889332?= X-GMAIL-MSGID: =?utf-8?q?1747576229857889332?= 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 56d5ccb5cc00..1c9af02eb63b 100644 --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c @@ -381,7 +381,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; @@ -819,7 +819,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); @@ -2104,7 +2104,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) & @@ -2187,7 +2187,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);