From patchwork Thu Oct 13 17:52:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 2229 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp412220wrs; Thu, 13 Oct 2022 11:10:08 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6mC+0+a7w86yCKjYapQUheg9uLXPInnDBoYiKtqv3Vp5mjKYQulMoI7hM38VcVRLjLCATG X-Received: by 2002:a17:90b:3e82:b0:20d:2fa1:d08d with SMTP id rj2-20020a17090b3e8200b0020d2fa1d08dmr12915179pjb.162.1665684608440; Thu, 13 Oct 2022 11:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665684608; cv=none; d=google.com; s=arc-20160816; b=Cu79FphKEisXkurlNBA6Hc1Ocv8qdJ+QiLXsP/RUh5eJe8TQe5vbS1AV/v72d0Kz+T A9oWjbinE7Yyfax7gIaHM/ensl42ZQzY3vClcywAdAyAKX7h41TCmm/YzT4BApMtFTGy uiD4b0y7trS8QBLTToeiM7x8KCw/Rx8R4C8LuGxLWY1RHL2vZK2BcdT4FZR3PK30FYr9 6IOe1nxQek4L7O4OurhtGf5S2Bl4uIg0rgo2rAwCDCI86BEujC6ODArS1Y2MMph3tDK2 qmyfowDOp/B/NhmI6FuGjt3JANbHRCP1NckON/BSl1sZvbTLHiVI5i7+pUxaQp0b4I9o 5Ipw== 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=4GVxEZ9y2rt0iK4DrnBH0LFAiNDjocNAdwdPVGD2JpY=; b=ivb2KIDAKWQa84vXC1IfSwp2a8VsjYKpcfIdDHxtuesps4vCbKuqS1Ywl+3SrvLfza O3ak90zLAT3H2qTBq7VukCNOXagDmU7OYGihLR3teyGJOM+GSQ9rOxJAhAT68SmrSJq9 ZXHYqGn4JrLbqP5zvqD+j54u0bxeu0KFXva2sV7U5RFmJiLfd9bKjl4u7mT59TzzWDjh ItgX0Qx1KWNGwu0v1Zd1qgpMFRZ/4kz1ZlMiK9zovf0+WcDhXwg0dfuw2msdAy5jrVWw UzFjncMpA8a/M5JgzNxbP3mPUAbbj/JOg6JZ4JYn5WZTtKRE1V5L+mkL5C6VleIEawm/ joKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=opAKSoT+; 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 l62-20020a638841000000b0044c7a49bef7si77387pgd.259.2022.10.13.11.09.55; Thu, 13 Oct 2022 11:10:08 -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=opAKSoT+; 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 S231320AbiJMSJp (ORCPT + 99 others); Thu, 13 Oct 2022 14:09:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231868AbiJMSI5 (ORCPT ); Thu, 13 Oct 2022 14:08:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EFC914FD34; Thu, 13 Oct 2022 11:06:39 -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 3C54C61A0D; Thu, 13 Oct 2022 18:01:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA8FCC4314E; Thu, 13 Oct 2022 18:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665684078; bh=4rWjydFXyLLDqW4rzOLOSOJ8MSOKHrz5swor8EvZv0k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=opAKSoT+UWpUDUlN3cQrkbLRdPJgg9jef+Ve4MW5Xy0NyJenCpg23YnXXPqhuw6ol TndVd7kw7GETWK+yflZEVp7Md9ELpDlTk8rA25sG6QLeFr1g1EXIKt6RS43TOkbMzc t5ktAJuAJXeKovoFe2MTEmcZLJ7JcM5fIEmU73ks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , Giovanni Cabiddu Subject: [PATCH 6.0 18/34] Revert "crypto: qat - reduce size of mapped region" Date: Thu, 13 Oct 2022 19:52:56 +0200 Message-Id: <20221013175146.994722955@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175146.507746257@linuxfoundation.org> References: <20221013175146.507746257@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 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?1746596903801740942?= X-GMAIL-MSGID: =?utf-8?q?1746596903801740942?= From: Giovanni Cabiddu commit 9c5f21b198d259bfe1191b1fedf08e2eab15b33b upstream. This reverts commit e48767c17718067ba21fb2ef461779ec2506f845. In an attempt to resolve a set of warnings reported by the static analyzer Smatch, the reverted commit improperly reduced the sizes of the DMA mappings used for the input and output parameters for both RSA and DH creating a mismatch (map size=8 bytes, unmap size=64 bytes). This issue is reported when CONFIG_DMA_API_DEBUG is selected, when the crypto self test is run. The function dma_unmap_single() reports a warning similar to the one below, saying that the `device driver frees DMA memory with different size`. DMA-API: 4xxx 0000:06:00.0: device driver frees DMA memory with different size [device address=0x0000000123206c80] [map size=8 bytes] [unmap size=64 bytes] WARNING: CPU: 0 PID: 0 at kernel/dma/debug.c:973 check_unmap+0x3d0/0x8c0\ ... Call Trace: debug_dma_unmap_page+0x5c/0x60 qat_dh_cb+0xd7/0x110 [intel_qat] qat_alg_asym_callback+0x1a/0x30 [intel_qat] adf_response_handler+0xbd/0x1a0 [intel_qat] tasklet_action_common.constprop.0+0xcd/0xe0 __do_softirq+0xf8/0x30c __irq_exit_rcu+0xbf/0x140 common_interrupt+0xb9/0xd0 The original commit was correct. Cc: Reported-by: Herbert Xu Signed-off-by: Giovanni Cabiddu Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/qat/qat_common/qat_asym_algs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) --- a/drivers/crypto/qat/qat_common/qat_asym_algs.c +++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c @@ -333,13 +333,13 @@ static int qat_dh_compute_value(struct k qat_req->out.dh.out_tab[1] = 0; /* Mapping in.in.b or in.in_g2.xa is the same */ qat_req->phy_in = dma_map_single(dev, &qat_req->in.dh.in.b, - sizeof(qat_req->in.dh.in.b), + sizeof(struct qat_dh_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.dh.r, - sizeof(qat_req->out.dh.r), + sizeof(struct qat_dh_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; @@ -730,13 +730,13 @@ static int qat_rsa_enc(struct akcipher_r qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.enc.m, - sizeof(qat_req->in.rsa.enc.m), + sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.enc.c, - sizeof(qat_req->out.rsa.enc.c), + sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params; @@ -876,13 +876,13 @@ static int qat_rsa_dec(struct akcipher_r qat_req->in.rsa.in_tab[3] = 0; qat_req->out.rsa.out_tab[1] = 0; qat_req->phy_in = dma_map_single(dev, &qat_req->in.rsa.dec.c, - sizeof(qat_req->in.rsa.dec.c), + sizeof(struct qat_rsa_input_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_in))) goto unmap_dst; qat_req->phy_out = dma_map_single(dev, &qat_req->out.rsa.dec.m, - sizeof(qat_req->out.rsa.dec.m), + sizeof(struct qat_rsa_output_params), DMA_TO_DEVICE); if (unlikely(dma_mapping_error(dev, qat_req->phy_out))) goto unmap_in_params;