Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2886697rwb; Mon, 15 Aug 2022 13:19:26 -0700 (PDT) X-Google-Smtp-Source: AA6agR7iXff1IhVs8jWzcA0ea7FPOcrmqwrnTqleynYHhCQrrVzauOFE3juNsKoBPnhB8xL6nrb6 X-Received: by 2002:a17:907:d25:b0:730:cdec:ab12 with SMTP id gn37-20020a1709070d2500b00730cdecab12mr11734275ejc.263.1660594766180; Mon, 15 Aug 2022 13:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594766; cv=none; d=google.com; s=arc-20160816; b=OoU+pooPbtF921B/f62TPPqZqEOO87UPzCVg0383Dor6ngnV1sY0H1qqlH/WsjmCie xgqiiISYnYCScCobP6tXdoRivnpmobJrQMmXV3GHYKsiOj2cuVzC+i+NnPlpTzayDNCe uAg/WOTlhSLKkvQBTEmVBWIAcIjZejaMzth6757FEvVO0HvkqrNo2Vcw7C6I+fHtEVbz vx1hNag175yegIGdf3sua/GZ2Qte1Ow/d1pFkmgkSf6tLCFU1phfsXwcmkuvUhB12J8F ba8vT00emXPa7HnpdCmIEzBb2Q48S4Ud91VqtlcMJO5kBgB9Q+FOqRk7Vy5VXfnA+hCY bnng== 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=d217eDodsz3z+e3gGwUv/PZ3pdTCvV2ZLRwaP41n+uc=; b=UI/LpQcD2Rla1VxJ/l/YokgG5bDPbBRyFYpVbRd4FQ6Babwtx9t4xzKS+LX2kQffSJ uMPjA8cFcg56mvr7aY3S+/GWP2q6firs/k7P9ub8QnU+iFv8TkTexSP5K8YheHvi6EkC htoP4tX2EEFVqawP/h37oJTdz1cbwM539aMLmaPW0jxWlqrER62+J0kwo6nlFCHt8QXv lfhSpraIfDl/Hc1Nh1BHzZSYJOfCmSMDguX2hfpBNX1RUDoPNKwTNhnu7wRHA1I0FmhF Oqfxyw8L802JfIgh3q8MceNg2JYHYdEN13rAD/tsVpPPOgBS60s9v4jFRet2+zO1Fz9U +nyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lZdtJReL; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a056402084500b0044301c7cd06si9695627edz.91.2022.08.15.13.18.59; Mon, 15 Aug 2022 13:19: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=lZdtJReL; 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 S245281AbiHOTEB (ORCPT + 99 others); Mon, 15 Aug 2022 15:04:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245351AbiHOS5R (ORCPT ); Mon, 15 Aug 2022 14:57:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AFDD32EF0; Mon, 15 Aug 2022 11:32:24 -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 3BDA160F7A; Mon, 15 Aug 2022 18:32:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A0C1C433C1; Mon, 15 Aug 2022 18:32:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588343; bh=87Ds+doF6FOF5oJqNQdMzwQexHSP157Ga24/dqnOdGk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lZdtJReLa785kAjb2gDkrNmnUy3kwrE3mRRkVPWcJn6vqmOcLqGjlhhpHMXg0YexH m7mz0U0G7WhlG5oQr6CtvL1uCz3t/OUDaTi939e4oIkV6EUcNedoc+9vBi7Zwk1Hnd Fzln4WzeyGYnV9EXpiDTn8S4hZU9rOJGGINTG0o8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Ye , Herbert Xu , Sasha Levin Subject: [PATCH 5.15 373/779] crypto: hisilicon/sec - fix auth key size error Date: Mon, 15 Aug 2022 20:00:17 +0200 Message-Id: <20220815180353.215358378@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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,T_SCC_BODY_TEXT_LINE 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 From: Kai Ye [ Upstream commit 45f5d0176d8426cc1ab0bab84fbd8ef5c57526c6 ] The authentication algorithm supports a maximum of 128-byte keys. The allocated key memory is insufficient. Fixes: 2f072d75d1ab ("crypto: hisilicon - Add aead support on SEC2") Signed-off-by: Kai Ye Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/hisilicon/sec2/sec_crypto.c | 6 +++--- drivers/crypto/hisilicon/sec2/sec_crypto.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.c b/drivers/crypto/hisilicon/sec2/sec_crypto.c index 36c789ff1bd4..0d26eda36a52 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -617,7 +617,7 @@ static int sec_auth_init(struct sec_ctx *ctx) { struct sec_auth_ctx *a_ctx = &ctx->a_ctx; - a_ctx->a_key = dma_alloc_coherent(ctx->dev, SEC_MAX_KEY_SIZE, + a_ctx->a_key = dma_alloc_coherent(ctx->dev, SEC_MAX_AKEY_SIZE, &a_ctx->a_key_dma, GFP_KERNEL); if (!a_ctx->a_key) return -ENOMEM; @@ -629,8 +629,8 @@ static void sec_auth_uninit(struct sec_ctx *ctx) { struct sec_auth_ctx *a_ctx = &ctx->a_ctx; - memzero_explicit(a_ctx->a_key, SEC_MAX_KEY_SIZE); - dma_free_coherent(ctx->dev, SEC_MAX_KEY_SIZE, + memzero_explicit(a_ctx->a_key, SEC_MAX_AKEY_SIZE); + dma_free_coherent(ctx->dev, SEC_MAX_AKEY_SIZE, a_ctx->a_key, a_ctx->a_key_dma); } diff --git a/drivers/crypto/hisilicon/sec2/sec_crypto.h b/drivers/crypto/hisilicon/sec2/sec_crypto.h index 9f71c358a6d3..ee2edaf5058d 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.h +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.h @@ -7,6 +7,7 @@ #define SEC_AIV_SIZE 12 #define SEC_IV_SIZE 24 #define SEC_MAX_KEY_SIZE 64 +#define SEC_MAX_AKEY_SIZE 128 #define SEC_COMM_SCENE 0 #define SEC_MIN_BLOCK_SZ 1 -- 2.35.1