Received: by 2002:a05:6520:4211:b029:f4:110d:56bc with SMTP id o17csp2112782lkv; Thu, 20 May 2021 03:42:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp6b/kZgejQ/2yS3famoiWbGQeA4OxhPvwIlhAZUy5Mu0GwXhSqvjy7Xy3QGvxBnxZp7dL X-Received: by 2002:a05:6e02:1067:: with SMTP id q7mr4312291ilj.75.1621507369516; Thu, 20 May 2021 03:42:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621507369; cv=none; d=google.com; s=arc-20160816; b=UKYywM0QfBGrCcwwHWaYyENC0hFa73/HBE7E7AUrbCRRsutphHHIXMIDii4rXU1Zqg sQvN/qxadSkwvrjeI5SWIAz5x+qoXGaEGCinXcFEwnbv+mKOkW4td9zKNSdLh9SYYby3 wRjdOZE3bgX6RtlZn5gWB0unzxVCUQGbxkfSqHRgyLAYC3V3PZ4Dt+A/ILlIUHrdxsyI I1bMPO8ITrCWrWai5sA3C7XRuYiQIibdQC9UNtViUQakYcTGNvTojBOHjO8CGGWmaa1n E5UNeQ6zzbjEQmNA58UWfavfi4WEHzJpXXhf/Nvn30s3HSWcXwjWM3Yr4XwtDeH85/oG qnbw== 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=GjVjyIG2R1CBKfxnAtn2GRGuQf7I6jDNd+ElJbxc/AOXMY7WFZth7s6lUmsJmnRkt4 1jG7I1MzWU9sSItuWsiFgxbqrSxlPnaEvz0azTsUN0eA852Qct0nNaiMb89vrqJ6yekd 7fwo/JjPsXW+A6EDN+PrBtJtHJ8IK3sfMjYCKkRRPIGYFqdme7vrLfPMUCqJ2rcTRkym 4WA8Fi+hlVtWbvFHqQoAhL6sQ3GJuIzR8Lqxkchomf02IB7gnkSpT9snjn0WdyckoniV LIT7Wvle2huiWApTs3udyIiIPjz0QdHSiFkvvlIMoEJbl2/L4HQrPc2oLPRqlIQRVjAw 9w5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1hxWhTUy; 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 y19si1730357jap.30.2021.05.20.03.42.34; Thu, 20 May 2021 03:42:49 -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=1hxWhTUy; 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 S236990AbhETKmn (ORCPT + 99 others); Thu, 20 May 2021 06:42:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:58796 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235758AbhETK1K (ORCPT ); Thu, 20 May 2021 06:27:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 39892613AD; Thu, 20 May 2021 09:50:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504228; bh=FQ35KVxQlmQFgep2aTte5/RLF+VqjXSwqseXN2IzYFE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1hxWhTUyRs8OOmdbXxzt0XCfdM6i9I+htPGN9f+ampc9yAwdBePKCsiq71o37aAn0 JOi6+4nDbbaAytUkfjS1J2VzpFIdkXRr0bOXvuGCUachK/tOmWQiuQJHqr4WLLQf1M HGWFvU7goUJvixpJ2bx/nwAfhTCTAgNHswj5it90= 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.14 150/323] crypto: qat - ADF_STATUS_PF_RUNNING should be set after adf_dev_init Date: Thu, 20 May 2021 11:20:42 +0200 Message-Id: <20210520092125.248019563@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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