Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1308053rwi; Thu, 13 Oct 2022 11:48:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM43SdixlX6OhiUmmz4NR5FVSPxwODoAFFkJnZsBFR5ubuAXhgu4iGMTXB/Yt2HAT7JwhkKx X-Received: by 2002:a63:e54:0:b0:46a:ff3d:5ee1 with SMTP id 20-20020a630e54000000b0046aff3d5ee1mr1157005pgo.194.1665686937086; Thu, 13 Oct 2022 11:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665686937; cv=none; d=google.com; s=arc-20160816; b=gB3c2bPPvhU9/qVP0zz5Gz9+cr/IYBFQTjaGUzoD24Oq3qmVoVcV9r0ifEXqIDg84P Vb5xBthlHOpwbfHTB0dxd5afFnfb8dCqWFJuvGIzsSelg4E9nngc+uea+HrziGHDJ4Tf d020FHm5sAluL3eAWYjZaegz2pCDF/owNuEMdTqLoAZD69RNOVXPbd9CJY0nPw599flW t4JL6VR9OQCjCIrx3+Ko1INMUOkau2qgrCYKIRicXk/7rGDBgwxKJ3l3wAIwmM12qNcf oeIWmNJXORbllhxhT4xTc5noF/rh9J9LbIyQejSnzeEKF7N6YDCojSpkfmPTLhPaibxr rxTA== 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=VDFdoGO/7z5YKhVQtioMncEKxb1vm6XVAHHTKcsmt88=; b=zh077p3v972MD4ro7gR1qvFzAWo/yDbEfJRDpw3x0+MD/Cl9/2tGXHvmC3V6V7Mxy5 ICCTzj2V13jVIjsldvbxlEDQkSfbwwYrZ3qivxsLKiGluXOs9tYbetX3uscbirvw7FCQ yqT33iuzato4ktEcCt4UspXdj1SI9APHRht66wTxNWhIvzzQM8cpawYzXKP49Ez4ZM7T CAKm+N5PfcXqJjuLr6inB4eyHAjK5zpn1m+Wcqnl1DLQ/WxJy3fYq9W0bXN6XZ48+rPy CtXTcA2fhJau4cvzehnyr47FgS0dj/SFj+sF3zH/B5uADlQ1wtYHAQfsR6ZRhJfT8Z5s TcVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TlL+2xlr; 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 q14-20020a17090311ce00b001789fa8f90esi514045plh.408.2022.10.13.11.48.45; Thu, 13 Oct 2022 11:48:57 -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=TlL+2xlr; 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 S230351AbiJMSBr (ORCPT + 99 others); Thu, 13 Oct 2022 14:01:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230354AbiJMSBf (ORCPT ); Thu, 13 Oct 2022 14:01:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9ED9144CFC; Thu, 13 Oct 2022 11:01:23 -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 1E36C61929; Thu, 13 Oct 2022 17:57:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EC87C43146; Thu, 13 Oct 2022 17:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1665683852; bh=C8RVSQSnVvD2a6CALdlWYB/J8V4HItUTJlCctPy9068=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TlL+2xlrfCGu3BrYNWiRzzl7rsN+zFAxJnguHxNmLxxewZ1xbwXMtumSdUtkHudQc xBmFDtms5IL/6+Ns8hhKrdEbmK5fI7Wz7gGBDrdPVwCdl0ZTxRCL4UJJrI1fFqVveQ LkpCVA6sdyMPokTleaaonZus+ykn5t9RQc6ndK78= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Herbert Xu , Giovanni Cabiddu Subject: [PATCH 5.15 13/27] Revert "crypto: qat - reduce size of mapped region" Date: Thu, 13 Oct 2022 19:52:42 +0200 Message-Id: <20221013175144.014828758@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221013175143.518476113@linuxfoundation.org> References: <20221013175143.518476113@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 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: 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 @@ -332,13 +332,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; @@ -728,13 +728,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; @@ -873,13 +873,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;