Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp340609pxj; Thu, 20 May 2021 10:30:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCG5Z4mlbmk1NDeGZ1dHCVM4hWSGOU77IcIeQcwdvivU5KF7EzRiolqVFACy8tUh4u0FVJ X-Received: by 2002:a17:906:dfcb:: with SMTP id jt11mr5664296ejc.362.1621531845782; Thu, 20 May 2021 10:30:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621531845; cv=none; d=google.com; s=arc-20160816; b=kNQD8OkxNYcWgu8nv0D+yRoUC377L9I5pDxCliPym5hEjr5usXyRTFJHm2jjDiVVgn PuNiy+bkBcoWNxh5yPcMUVJUsdaWN5GerpyIMgAc2z8bKOYR9QeXfvhY6XS/pMAxAhrb aCRsAkwa7GGLuGFLrY8J2Tx9LzC+TAbUUEDdr/3+ljedg1ofs+4nvgLWny/ebGN9Le7T HqgVJ9lmFBbN+MWxKcJm2nIas9tnnbvKTTG/RNMshTAfoHLDfUxpvIET4ioIrlMD5cEh Ipg51RJnBfTEpzCvyPFw5SwlQADsDYpiQgiGIsEIbXHov69NsZgGzGzRjvQUTeIbIvMQ Wc/A== 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=ITuN0z98h6DjFL2krXyhr3d2/bdVq/JlzBxuuHYoNcY=; b=QvBFSKrENxGkWqDTh03RFy2zKobdNbrwfQVeNeqrOLXfO6VhIA5PjXsTRhbCvau3FR r4PyDobDUlxkpIEQIGqqr/MzWbzCEP/7FM52SwsjR7E7xQXPT2uZbJpWVF6msP2ZHia6 tBJlECm8QXX0Le3b12Lhs2k7ucfIpCP15NftCPEAVl03cHVY497hTve6GhjPQeMvpIEO rofZNGsXmPljX3mPvFi3OTwRI5O/FQvJW9Od2blgY6OTW9lFHQL6DDh7S6bDgUDNdt5k w204xk0aTnaMbLjv6IMpn9dA0xLnoXrrf71y8XQZQXArgC1YMG5pyw5a4Yd1WkKAFXC1 8M2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Il+07qjw; 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 z62si3212526ede.508.2021.05.20.10.30.22; Thu, 20 May 2021 10:30:45 -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=Il+07qjw; 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 S234759AbhETJ6K (ORCPT + 99 others); Thu, 20 May 2021 05:58:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:53920 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234739AbhETJyT (ORCPT ); Thu, 20 May 2021 05:54:19 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D8E36124C; Thu, 20 May 2021 09:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503411; bh=FQ35KVxQlmQFgep2aTte5/RLF+VqjXSwqseXN2IzYFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Il+07qjwRRgWS8X6i5kvcNJ7lfXy+45pas3DW0HDX4Oie3XUq7GvBCElobtCxu5lW o7Uez3Rl7d/q98TfGGspuj/g0h1hWjwjSvXn5iEesgATjk9DqVxhCv/SAmetdaG+e3 XiE/vtjZ0nhaai5LNF+C75x63SDKGSaVUS/RbL+8= 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 4.19 182/425] crypto: qat - ADF_STATUS_PF_RUNNING should be set after adf_dev_init Date: Thu, 20 May 2021 11:19:11 +0200 Message-Id: <20210520092137.409597245@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 613c7d5644ce..e87b7c466bdb 100644 --- a/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +++ b/drivers/crypto/qat/qat_c3xxxvf/adf_drv.c @@ -238,12 +238,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 278452b8ef81..a8f3f2ecae70 100644 --- a/drivers/crypto/qat/qat_c62xvf/adf_drv.c +++ b/drivers/crypto/qat/qat_c62xvf/adf_drv.c @@ -238,12 +238,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 3da0f951cb59..1b954abf67fb 100644 --- a/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +++ b/drivers/crypto/qat/qat_dh895xccvf/adf_drv.c @@ -238,12 +238,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