Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3091198rwb; Mon, 15 Aug 2022 17:54:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR7fmPgYAVV9ULkq98ohAZWDDoz9oUt5V8o3tBLZ+UVvJcQLqCU8b31mwuYgT8R1Um2Go8mk X-Received: by 2002:a17:907:7f8b:b0:734:b422:42e7 with SMTP id qk11-20020a1709077f8b00b00734b42242e7mr11802916ejc.225.1660611208298; Mon, 15 Aug 2022 17:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611208; cv=none; d=google.com; s=arc-20160816; b=L5XDEou62Wnzz/6+9AlzriGPkcTvPRsYaWglX8CxjzLLTqfjLXdO6yjUF5kLpusZYo Yh5O4j0eLUOTh/7d4Yoo1gMxrnV3HfWwpevEaqwov0eAIuRx2RYHrW2Rx6QXKOMvEryR Gki1aIZ7o5Jt0VG2mtVGrl86RG9amhlQECnrgDS7uLeoM5MngVhnXx2ePDiseLlBdNxr FPtXHUZ827d7Ez4gSwq3cJn/v2vU6qNQO3SHfxkxgploNbFW92DZ5A0ZEuGihjh9bEjX iYHkSpWRte39H8rW2Usu4DmItZiLpPeWOyTgoyfXCYYz/UvyXMYotYxue3ley8+nFPnn r4HQ== 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=MCTMUTzvlJcjGY4IVZaOqQsw32YSRO0S9OxMSwy7Cto=; b=U88OlXQg/yi4XX99ongtPwnjIkSLikQ9OthN9wR+SktQd3iCb9PHW0Q6nnu5TMG9FX XvoEb4mhazhcciiz7i+NQXtQ+QbEaUT6RMf1P9x7RwolxOVot7A/PKJm4IY1Nptdl/+k MNzJiDUYADNO+QcxSit3qjQ9yxPDUmbL2y6xfDR4CvnPdwzC55MsrRUSfxoaRr96o9kJ kieSmwem6EGgttPq577FvjWu97qEvPqtfoqKdwPlOM2erOExDiX1h4R6zhqZaLrqVwXT LnUoYQUabUnrEDFWltmIqIUllnVdrztreGazrgM91LVbxfdNkuTpRy47M4goWB74Aaj6 kE9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="TWg1J/ei"; 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 o7-20020a056402438700b0043bd87c7abesi9517567edc.34.2022.08.15.17.53.02; Mon, 15 Aug 2022 17:53:28 -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="TWg1J/ei"; 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 S1343996AbiHPAEV (ORCPT + 99 others); Mon, 15 Aug 2022 20:04:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356586AbiHOXyo (ORCPT ); Mon, 15 Aug 2022 19:54:44 -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 E297F162C65; Mon, 15 Aug 2022 13:19:48 -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 56442B81136; Mon, 15 Aug 2022 20:19:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9CA9DC433D6; Mon, 15 Aug 2022 20:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594787; bh=YxnjGagAXKYwl9x1vFjIhlV6RfgjGjLrQnuVa5abR54=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TWg1J/eirIa7cOvqgNWs0YczZBopDwGiK3u9wDB7WczbzVRoVGH1hxRDXD5f2KnPe 0IgZtC2X8V54OyWkxETTKSoqJZv4yr6CNKT+f7RJVJgMUDxO4fvJ2DixUb367NW+iW 7RrH+zXDlo4m5MNEpozA0eMe24CH3aXzhhdSrGjg= 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.19 0559/1157] crypto: hisilicon/sec - fix auth key size error Date: Mon, 15 Aug 2022 19:58:35 +0200 Message-Id: <20220815180501.978638099@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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 71dfa7db6394..77c9f13cf69a 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