Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp672640pxf; Thu, 18 Mar 2021 09:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH3eYBJgV++8X5uCgCyU/auCQF8Yn1A5OeXbMIy36SmGarTHFK431ipgBt4cln4L7YwVRd X-Received: by 2002:a05:6402:382:: with SMTP id o2mr4663505edv.238.1616083478463; Thu, 18 Mar 2021 09:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616083478; cv=none; d=google.com; s=arc-20160816; b=BRgAYoQ1Qmx3mumomr0TxNVO0UH6jZ8bp84YCnN1Kq16fWTL45gdZpHxnNfI/Rgs89 THtaqYe4mievDWWlH/o59LMLOjOBNpeXaR3dkz3xAQPzVbS2reKfK71nU0YL+AyAFR4T 3JlixPBhPeu9fu2u0rOBAl+qkhxYrm12SCpNfO0GaDl4bnKkOoxYOhWaJp7Ht0Neo0TN JxDnBfCnMMisrLeFeWEYv4j5FxPqQNziqIWhExzfCHZHNiCr3rl7dbp91BiZdT+b3BNr Wp5jCdjomY2Bkcxq32sIAcOP08dJx6f4KZmyGWgfxejPoacI5F8gEP1Y02GxAWJETADw rv8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=A2Vj0bKqAa2QFYyF7y9pJQa1V5THtRPjrjEH3PsI4i8=; b=BlaY/cOr/b9LozdiWekhThWYNDM/yEH1ewkRvFhETAW6jNHyOEagpFizSYTMvq2LgD vyDfUT1LRjdtTG9a73UKrMz5sVELJVOW+7u6leEv0hfeSxykUgsyog6OhJiuWHPzXeHs tegetjeNsetHOH7H/mm7c5rF4vuaI7/SnvD9Ncdpdk5I2qMyfW/NFwpJ4xAuZF9OhRPv UnjaOX2FAwn+oA5GnGw/FMRqAbv+00istklXyouzQs3mIUfurcC48FD+ibvWLcwFVlXU HcMB0pUYC9GaskR6NlQqj4aH3wRmVy1rcbysCfrgtox36np+YKXy2zNexQfR0m5YbVgL EnwA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i5si1878372ejh.313.2021.03.18.09.04.13; Thu, 18 Mar 2021 09:04:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231737AbhCRQDi (ORCPT + 99 others); Thu, 18 Mar 2021 12:03:38 -0400 Received: from mga17.intel.com ([192.55.52.151]:55696 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231925AbhCRQDe (ORCPT ); Thu, 18 Mar 2021 12:03:34 -0400 IronPort-SDR: +ri1HT9dh7IQA3ZlmDiFptEC6Bvn821e1C1XlQszz3UQ2PCYwnfEiS1qjDXWMYYrNRLWGna6KB CMYPb3ZPWMFw== X-IronPort-AV: E=McAfee;i="6000,8403,9927"; a="169635626" X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="169635626" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 09:03:23 -0700 IronPort-SDR: PdEnANYGgfWKRr8umKH1trKxkkoyulhy96JuwUPdNKPhiF+N8KPZmRs1fK5CAmbWwAvjQYcXaP mH2qtnpoBKBQ== X-IronPort-AV: E=Sophos;i="5.81,259,1610438400"; d="scan'208";a="389292774" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314) ([10.237.222.51]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2021 09:03:14 -0700 Date: Thu, 18 Mar 2021 16:03:09 +0000 From: Giovanni Cabiddu To: Tong Zhang Cc: Herbert Xu , "David S. Miller" , Andy Shevchenko , Wojciech Ziemba , Fiona Trahe , qat-linux@intel.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init Message-ID: References: <20210312162203.2416149-1-ztong0001@gmail.com> <20210312162203.2416149-3-ztong0001@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210312162203.2416149-3-ztong0001@gmail.com> Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Mar 12, 2021 at 11:22:03AM -0500, Tong Zhang wrote: > 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 > --- > 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 1d1532e8fb6d..067ca5e17d38 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 04742a6d91ca..51ea88c0b17d 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 c972554a755e..29999da716cc 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.25.1 >