Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1966722rdb; Sun, 19 Nov 2023 19:13:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHx9gH59O/CKsLjRBRR8FAyZLWCzQFKk9zD8F+MjpUoXKcjrtB+g6kBES75yTvfITYfubUs X-Received: by 2002:a17:903:264a:b0:1cc:2771:6fbe with SMTP id je10-20020a170903264a00b001cc27716fbemr4249384plb.39.1700450017935; Sun, 19 Nov 2023 19:13:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700450017; cv=none; d=google.com; s=arc-20160816; b=HDknH/0m6w4oC505VzsmqpxwuyGPi4Iu1onvUfe3knapAG5/oMhceg4dgheRLFW7sS TfHa4+/PHAZ98NkZA0SSfvyc/axh0+n/JTsy47D0HxOmy86f9d+EOHZ8boKDheWU9CIA watDQ4EV7C2Zv4ctNWH0wuF2mzMYf1zjUjNVjc+fl+Hm3IZGNrkohDs+eoTPuOqv38P8 L9OMgZeTXpf9xHn9/VwOcY7DpalFo9a1p5lqg4L56kzxPbKE4rUAkGzzfwrRKPsfisAU kg/JggF50FT33zgi6w8Z04C26XZI9rGT8k0vZ8M1wpG14J4ZY8wriRGbmaHtmkxFJ6mS lLRg== 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 :message-id:date:subject:cc:to:from; bh=y/dcIqyK976sF5dJbMKZbbmbmbLaw1PVuAXcPsyLE0E=; fh=rdnr+FoQmbAgUxGRzMEhZp29EPUhv/mZBRcLrPi0wBM=; b=ie2FBGUzzxD1gmcByGTCNsqHnITbxPi0BbtdzgoqCPIQacH0nzFkUFqs5Y/8WJxfHQ sR3xmycuyyB0N09bXNa1y2h9QZFp7dY1YjNaUR5qmRz4Hv952X1bT33RK98QoX14CGmU ff1kGmn02K6MXp7Fq6eYvA45A647eKa5vHcwvs9op6q1PgO9y7+qky2W8uvAyKBDejq9 zBeBIkvMViVHnJRWWEaPagXnw9Nf13+3PAYCspB+UMXq6AHBEp76wvYf1rLORE790C3L UUhSsB7cCMHjzo64fsiYlTCX4tqKtKRQOp4KikMA0hCJrDXqyVFyrA84iwwVGxxWOzZ/ Ptlw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id z22-20020a1709028f9600b001ce663d7930si5164303plo.47.2023.11.19.19.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 19:13:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 8248E80972B7; Sun, 19 Nov 2023 19:13:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231807AbjKTDNO convert rfc822-to-8bit (ORCPT + 99 others); Sun, 19 Nov 2023 22:13:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229596AbjKTDNN (ORCPT ); Sun, 19 Nov 2023 22:13:13 -0500 Received: from ex01.ufhost.com (ex01.ufhost.com [61.152.239.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9D71129; Sun, 19 Nov 2023 19:13:04 -0800 (PST) Received: from EXMBX166.cuchost.com (unknown [175.102.18.54]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "EXMBX166", Issuer "EXMBX166" (not verified)) by ex01.ufhost.com (Postfix) with ESMTP id E977B24E24C; Mon, 20 Nov 2023 11:12:50 +0800 (CST) Received: from EXMBX168.cuchost.com (172.16.6.78) by EXMBX166.cuchost.com (172.16.6.76) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 20 Nov 2023 11:12:50 +0800 Received: from ubuntu.localdomain (161.142.156.101) by EXMBX168.cuchost.com (172.16.6.78) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 20 Nov 2023 11:12:46 +0800 From: Jia Jie Ho To: Herbert Xu , "David S . Miller" CC: , Subject: [PATCH v2] crypto: starfive - Pad adata with zeroes Date: Mon, 20 Nov 2023 11:12:42 +0800 Message-ID: <20231120031242.25100-1-jiajie.ho@starfivetech.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [161.142.156.101] X-ClientProxiedBy: EXCAS064.cuchost.com (172.16.6.24) To EXMBX168.cuchost.com (172.16.6.78) X-YovoleRuleAgent: yovoleflag Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sun, 19 Nov 2023 19:13:35 -0800 (PST) Aad requires padding with zeroes up to 15 bytes in some cases. This patch increases the allocated buffer size for aad and prevents the driver accessing uninitialized memory region. v1->v2: Specify reason for alloc size change in descriptions. Signed-off-by: Jia Jie Ho --- drivers/crypto/starfive/jh7110-aes.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/starfive/jh7110-aes.c b/drivers/crypto/starfive/jh7110-aes.c index 9378e6682f0e..e0fe599f8192 100644 --- a/drivers/crypto/starfive/jh7110-aes.c +++ b/drivers/crypto/starfive/jh7110-aes.c @@ -500,7 +500,7 @@ static int starfive_aes_prepare_req(struct skcipher_request *req, scatterwalk_start(&cryp->out_walk, rctx->out_sg); if (cryp->assoclen) { - rctx->adata = kzalloc(ALIGN(cryp->assoclen, AES_BLOCK_SIZE), GFP_KERNEL); + rctx->adata = kzalloc(cryp->assoclen + AES_BLOCK_SIZE, GFP_KERNEL); if (!rctx->adata) return dev_err_probe(cryp->dev, -ENOMEM, "Failed to alloc memory for adata"); @@ -569,7 +569,7 @@ static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq struct starfive_cryp_ctx *ctx = crypto_aead_ctx(crypto_aead_reqtfm(req)); struct starfive_cryp_dev *cryp = ctx->cryp; - struct starfive_cryp_request_ctx *rctx = ctx->rctx; + struct starfive_cryp_request_ctx *rctx; u32 block[AES_BLOCK_32]; u32 stat; int err; @@ -579,6 +579,8 @@ static int starfive_aes_aead_do_one_req(struct crypto_engine *engine, void *areq if (err) return err; + rctx = ctx->rctx; + if (!cryp->assoclen) goto write_text; -- 2.34.1