Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4592220pxj; Wed, 12 May 2021 08:51:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwahEnsLGe++iJat4B3WGZM6RrcsM+x+wPvJdEE/tW0RJvZv9W2c+vGt1JKdvKfhZdEVcd0 X-Received: by 2002:a17:906:9892:: with SMTP id zc18mr3039239ejb.354.1620834680968; Wed, 12 May 2021 08:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834680; cv=none; d=google.com; s=arc-20160816; b=N39Kw/vLOZy5qAojLbRs/cC2Ztyx+XmL9g5seMfEsX4Q/1C1KCYbFckkcwksyj1IxR WaqAxfDNmjY57hkVauF02RQL5qGKzqx7q0nPDMC9DcsAVarY9gLIt70TiRjsSqheKfr1 +gksekrghnvXLKx9+OgBSJlcBJKKqcnQu1EmoT6qHo5tCAEVBVaYiBOunAkr8spL1ehx 5qOlAQvnafPS+4ieia6eq5lM1Nhx/Q3GQll2ttL3pNNUc3hLvNKhDVBeDnHA916bKcOg UqoQ6+/GzYk7cjrswrSTtT39P+Ubs7VSberq0AZ75pNVKNUcnXj+moQbL6v0VjwjI7Gm wQFg== 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=f71yAtPSnfz6Ek5bpzMnbs/af6j7PgVL05BJNbO5ryY=; b=kiWgtinIGy8gWvwq3VwTDXr09zIqTc6Y0+sAMEJd8FLsnJM5AQ3fGwHI/ycWCysFV6 4g8Qsvhu+QTM5SRr7HDTAeVVmiSDtU5yA6P3OZveflkFXTo98WXLLvu7IG/mxe4Kv/OC PotKWa0lLPf1MWAEawxcmmVubzXwCP3UI3Lix6L4jQi5wgCOzIivmX+Nz2Fmup822ibM U2ucc9zcUBBXOJmA7mEynkAMOsgLc5TWEBIBX+7IQauME9BfJZrl1AHEl4oQsXIJz5EW tnQ0+dpWSyO+CbZbcGhsqm82tchiV/mARNpzWOpYOhnPn1VZuP8WHNGudxw4EgKPY8yS nBxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OZXiRnvi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si107124edd.260.2021.05.12.08.50.55; Wed, 12 May 2021 08:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OZXiRnvi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S235650AbhELPtd (ORCPT + 99 others); Wed, 12 May 2021 11:49:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:59890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234230AbhELPXz (ORCPT ); Wed, 12 May 2021 11:23:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D6A9B619B2; Wed, 12 May 2021 15:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832185; bh=mTxkDOAV7u0m9AgELgB39BWU0MXQ2y8nrxAcpuQ1XIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZXiRnvi1uPswRVNmgA86h1zpi+PAn+ROmLYdluGVLWALEa2Sc3lVfpKY9Qe3hpKZ INGavReG+ZblyHb+WYezbMJeztK1SlWZBnKjn4BgOTQ0QfPAYybyeF6ThslmjaH2JZ GMcycIEvLMC3qotOJs08EzBYVSVRSN7TlR5jWztE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tong Zhang , Andy Shevchenko , Giovanni Cabiddu , Herbert Xu , Sasha Levin Subject: [PATCH 5.10 175/530] crypto: qat - ADF_STATUS_PF_RUNNING should be set after adf_dev_init Date: Wed, 12 May 2021 16:44:45 +0200 Message-Id: <20210512144825.586463985@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tong Zhang [ Upstream commit 8609f5cfdc872fc3a462efa6a3eca5cb1e2f6446 ] ADF_STATUS_PF_RUNNING is (only) used and checked by adf_vf2pf_shutdown() before calling adf_iov_putmsg()->mutex_lock(vf2pf_lock), however the vf2pf_lock is initialized in adf_dev_init(), which can fail and when it fail, the vf2pf_lock is either not initialized or destroyed, a subsequent use of vf2pf_lock will cause issue. To fix this issue, only set this flag if adf_dev_init() returns 0. [ 7.178404] BUG: KASAN: user-memory-access in __mutex_lock.isra.0+0x1ac/0x7c0 [ 7.180345] Call Trace: [ 7.182576] mutex_lock+0xc9/0xd0 [ 7.183257] adf_iov_putmsg+0x118/0x1a0 [intel_qat] [ 7.183541] adf_vf2pf_shutdown+0x4d/0x7b [intel_qat] [ 7.183834] adf_dev_shutdown+0x172/0x2b0 [intel_qat] [ 7.184127] adf_probe+0x5e9/0x600 [qat_dh895xccvf] Signed-off-by: Tong Zhang Reviewed-by: Andy Shevchenko Fixes: 25c6ffb249f6 ("crypto: qat - check if PF is running") Acked-by: Giovanni Cabiddu Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c b/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c index 456979b136a2..ea932b6c4534 100644 --- a/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +++ b/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c @@ -184,12 +184,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto out_err_free_reg; - set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); - ret = adf_dev_init(accel_dev); if (ret) goto out_err_dev_shutdown; + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); + ret = adf_dev_start(accel_dev); if (ret) goto out_err_dev_stop; diff --git a/drivers/crypto/qat/qat_c62xvf/adf_drv.c b/drivers/crypto/qat/qat_c62xvf/adf_drv.c index b9810f79eb84..6200ad448b11 100644 --- a/drivers/crypto/qat/qat_c62xvf/adf_drv.c +++ b/drivers/crypto/qat/qat_c62xvf/adf_drv.c @@ -184,12 +184,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto out_err_free_reg; - set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); - ret = adf_dev_init(accel_dev); if (ret) goto out_err_dev_shutdown; + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); + ret = adf_dev_start(accel_dev); if (ret) goto out_err_dev_stop; diff --git a/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c b/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c index 404cf9df6922..737508ded37b 100644 --- a/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +++ b/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c @@ -184,12 +184,12 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) if (ret) goto out_err_free_reg; - set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); - ret = adf_dev_init(accel_dev); if (ret) goto out_err_dev_shutdown; + set_bit(ADF_STATUS_PF_RUNNING, &accel_dev->status); + ret = adf_dev_start(accel_dev); if (ret) goto out_err_dev_stop; -- 2.30.2