All of lore.kernel.org
 help / color / mirror / Atom feed
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: Tong Zhang <ztong0001@gmail.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Wojciech Ziemba <wojciech.ziemba@intel.com>,
	Fiona Trahe <fiona.trahe@intel.com>,
	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
Date: Thu, 18 Mar 2021 16:03:09 +0000	[thread overview]
Message-ID: <YFN5vZ97mHNbl6Bx@silpixa00400314> (raw)
In-Reply-To: <20210312162203.2416149-3-ztong0001@gmail.com>

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 <ztong0001@gmail.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Fixes: 25c6ffb249f6 ("crypto: qat - check if PF is running")
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>

> ---
>  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
> 

      reply	other threads:[~2021-03-18 16:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-12 16:22 [PATCH v3 0/2] crypto: qat: fix couple crashes duing error handling Tong Zhang
2021-03-12 16:22 ` [PATCH v3 1/2] crypto: qat - dont release uninitialized resources Tong Zhang
2021-03-18 15:53   ` Giovanni Cabiddu
2021-03-18 16:06     ` Giovanni Cabiddu
2021-03-18 16:21       ` [PATCH v4 0/2] crypto: qat: fix couple crashes duing error handling Tong Zhang
2021-03-18 16:21       ` [PATCH v4 1/2] crypto: qat - don't release uninitialized resources Tong Zhang
2021-03-18 16:21       ` [PATCH v4 2/2] crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init Tong Zhang
2021-03-18 17:17         ` Giovanni Cabiddu
2021-03-19  3:39           ` [PATCH v5 0/2] crypto: qat - fix couple crashes duing error handling Tong Zhang
2021-03-19  3:39             ` [PATCH v5 1/2] crypto: qat - don't release uninitialized resources Tong Zhang
2021-03-19  3:40             ` [PATCH v5 2/2] crypto: qat - ADF_STATUS_PF_RUNNING should be set after adf_dev_init Tong Zhang
2021-03-26  9:31             ` [PATCH v5 0/2] crypto: qat - fix couple crashes duing error handling Herbert Xu
2021-03-19  3:41           ` [PATCH v4 2/2] crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init Tong Zhang
2021-03-18 16:22       ` [PATCH v3 1/2] crypto: qat - dont release uninitialized resources Tong Zhang
2021-03-12 16:22 ` [PATCH v3 2/2] crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init Tong Zhang
2021-03-18 16:03   ` Giovanni Cabiddu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YFN5vZ97mHNbl6Bx@silpixa00400314 \
    --to=giovanni.cabiddu@intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=davem@davemloft.net \
    --cc=fiona.trahe@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qat-linux@intel.com \
    --cc=wojciech.ziemba@intel.com \
    --cc=ztong0001@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.