Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2940224rwb; Mon, 15 Aug 2022 14:29:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR7tgki5FB86nYrupCJ9SFSqiQ1t5fpd07rg6CRiPL3k5kjOMfiLLnmaxJlSKTncrJQFGISU X-Received: by 2002:a62:3086:0:b0:52b:fd6c:a49d with SMTP id w128-20020a623086000000b0052bfd6ca49dmr17560406pfw.26.1660598964807; Mon, 15 Aug 2022 14:29:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598964; cv=none; d=google.com; s=arc-20160816; b=n13UBCv4ezBfTFa3GcuFHLGQ8DTb7RaY/IxzCcAj6jHjh0mHQSGkXhogKREgXMDkIy PstZMm/H4M4ludqEaX2wsixB7TlxxdSUseC5mRDUtAHFYu5WX7AX4B7CYYrxM+vVbvwE 1Fn5hM5jHIB8H09YYwt1DlEdfnWQrmMntQhSv6oQtR9rR8g8KifuI+irrinzmi1BURUh uuK9778P33tg+NOH9ZMOAFiOdRrhLV4PCeJCgygaXR3hNeknmmyY/T1bludtvvLiM09i 00apNboz7a7bZ/DyVw9m2AxLXz6hrrKrZh4iQ1zOTRZo8LNkMo9Nn+OHyaupBs6rQrvz 1XRw== 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=xdc7FGwJfwi9LKquQ8BryewkatUyBVhjn+H/ux6bml8=; b=w/6WOUP513fcJ3E/SHZfaCe4TTwctxdWiwINo9kw+TpFqxvDr7DZAY4ZJSOfv62MKp 0r+P2K031KKQiKsDZRwHNxjO6rqBD2k6cY/Q4MVMkb9Vjp/ijJc6koaHfNFj0Rpidf+5 5Ha0LPyVwdfoJQvXzS8bYwCR03aCCI5oUbyV1vBfiTIo78CbRRnhKhQV4WOuFlIrSvvz oIuinkOFDABpXf6bjWusa0DHt51CIGOF4urTAl4kYtHuAwW1CG2+Xqs/eSvnuPQuBS7E mSwSIobzfII/o6ia7KFPndTGMKc7N5LDsafbbDdigEgATNBbZYNE0/tflvqj2Aikbb+4 8ePQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vMO48c0Z; 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 kk18-20020a17090b4a1200b001f2082e15fcsi12498194pjb.3.2022.08.15.14.29.11; Mon, 15 Aug 2022 14:29:24 -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=vMO48c0Z; 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 S1347707AbiHOV0J (ORCPT + 99 others); Mon, 15 Aug 2022 17:26:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345376AbiHOVRq (ORCPT ); Mon, 15 Aug 2022 17:17:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C0D58B77; Mon, 15 Aug 2022 12:21: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 E9E7360FDA; Mon, 15 Aug 2022 19:21:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B70E3C433D6; Mon, 15 Aug 2022 19:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591262; bh=V8KFlUt8vc+S/5k6oJNap1osqTZ/7ZMM2KhwKESJ2xM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vMO48c0ZtCNxfe60URy3MdIBmgqIDagb1cmvFvxJYg9pTMJIQgYPtV2AAD7n7nGIu cDl/zoQvX9TMjf4bBAaWuLd7z77DyBqIGmeZr2Am32Zn1+imzX6rsWOM5XiKB8G0iL zLBKImH7xPbe2bdYRl0i/rAexLABipug7t5BAbBs= 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.18 0523/1095] crypto: hisilicon/sec - fix auth key size error Date: Mon, 15 Aug 2022 19:58:42 +0200 Message-Id: <20220815180451.193254865@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 f193d6b6fa16..dbaa6c918cfd 100644 --- a/drivers/crypto/hisilicon/sec2/sec_crypto.c +++ b/drivers/crypto/hisilicon/sec2/sec_crypto.c @@ -620,7 +620,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; @@ -632,8 +632,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 5e039b50e9d4..d033f63b583f 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