crypto: qat: fix couple crashes duing error handling
v3 cover crypto: qat: fix couple crashes duing error handling
There are a couple of issues in qat error handling. Those drivers tries to release resources that is not initialized. This patch series tries to fix crashes caused by incorrect error handling.
v2: removed excessive dump in commit log as suggested by Andy Shevchenko <[email protected]>
v3: collect tags as suggested by Andy Shevchenko <[email protected]>
Tong Zhang (2):
crypto: qat - dont release uninitialized resources
crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
PATCH v3 1/2 crypto: qat - dont release uninitialized resources
adf_vf_isr_resource_alloc() is not unwinding correctly when error happens and it trys to release uninitialized resources. To fix this, only release initialized resources.
[ 1.792845] Trying to free already-free IRQ 11 [ 1.793091] WARNING: CPU: 0 PID: 182 at kernel/irq/manage.c:1821 free_irq+0x202/0x380 [ 1.801340] Call Trace: [ 1.801477] adf_vf_isr_resource_free+0x32/0xb0 [intel_qat] [ 1.801785] adf_vf_isr_resource_alloc+0x14d/0x150 [intel_qat] [ 1.802105] adf_dev_init+0xba/0x140 [intel_qat]
--- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/crypto/qat/qat_common/adf_vf_isr.c +13 -4
@@ -261,17 +261,26 @@ int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev) goto err_out;if (adf_setup_pf2vf_bh (accel_dev)) - goto err_out; + goto err_disable_msi;if (adf_setup_bh (accel_dev)) - goto err_out; + goto err_cleanup_pf2vf_bh;if (adf_request_msi_irq (accel_dev)) - goto err_out; + goto err_cleanup_bh;return 0 ; + +err_cleanup_bh: +adf_cleanup_bh (accel_dev); + +err_cleanup_pf2vf_bh: +adf_cleanup_pf2vf_bh (accel_dev); + +err_disable_msi: +adf_disable_msi (accel_dev); + err_out: -adf_vf_isr_resource_free (accel_dev);return -EFAULT ; }EXPORT_SYMBOL_GPL (adf_vf_isr_resource_alloc);
Signature · 1 line
2.25.1
Re: [PATCH v3 1/2] crypto: qat - dont release uninitialized resources
Quoted 11 lines · Tong Zhang
adf_vf_isr_resource_alloc()is not unwinding correctly when error happens and it trys to release uninitialized resources. To fix this, only release initialized resources.[ 1.792845] Trying to free already-free IRQ 11 [ 1.793091] WARNING: CPU: 0 PID: 182 at kernel/irq/manage.c:1821 free_irq+0x202/0x380 [ 1.801340] Call Trace: [ 1.801477] adf_vf_isr_resource_free+0x32/0xb0 [intel_qat] [ 1.801785] adf_vf_isr_resource_alloc+0x14d/0x150 [intel_qat] [ 1.802105] adf_dev_init+0xba/0x140 [intel_qat]
Quoted 2 lines
Signed-off-by Tong Zhang <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
I would add also a Fixes tag:
Minor nit, typo in commit message: dont --> don't/do not
Apart from that
Signature · 1 line
Giovanni
Quoted 42 lines
--- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)drivers/crypto/qat/qat_common/adf_vf_isr.c +13
-4@@ -261,17 +261,26 @@ int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev) goto err_out;if (adf_setup_pf2vf_bh (accel_dev)) - goto err_out; + goto err_disable_msi;if (adf_setup_bh (accel_dev)) - goto err_out; + goto err_cleanup_pf2vf_bh;if (adf_request_msi_irq (accel_dev)) - goto err_out; + goto err_cleanup_bh;return 0 ; + +err_cleanup_bh: +adf_cleanup_bh (accel_dev); + +err_cleanup_pf2vf_bh: +adf_cleanup_pf2vf_bh (accel_dev); + +err_disable_msi: +adf_disable_msi (accel_dev); + err_out: -adf_vf_isr_resource_free (accel_dev);return -EFAULT ; }EXPORT_SYMBOL_GPL (adf_vf_isr_resource_alloc);Signature · 1 line
2.25.1
Re: [PATCH v3 1/2] crypto: qat - dont release uninitialized resources
Quoted 3 lines · Giovanni Cabiddu
Quoted 2 lines · Tong Zhang
adf_vf_isr_resource_alloc()is not unwinding correctly when error happens and it trys to release uninitialized resources.
^^^^
Typo: perhaps 'tries'?
Regards,
Signature · 1 line
Giovanni
v4 cover crypto: qat: fix couple crashes duing error handling
There are a couple of issues in qat error handling. Those drivers tries to release resources that is not initialized. This patch series tries to fix crashes caused by incorrect error handling.
v2: removed excessive dump in commit log as suggested by Andy Shevchenko <[email protected]>
v3: collect tags as suggested by Andy Shevchenko <[email protected]>
v4: fix commit log typos
Tong Zhang (2):
crypto: qat - dont release uninitialized resources
crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
PATCH v4 1/2 crypto: qat - don't release uninitialized resources
In reply to Giovanni Cabidduadf_vf_isr_resource_alloc() is not unwinding correctly when error happens and it tris to release uninitialized resources. To fix this, only release initialized resources.
[ 1.792845] Trying to free already-free IRQ 11 [ 1.793091] WARNING: CPU: 0 PID: 182 at kernel/irq/manage.c:1821 free_irq+0x202/0x380 [ 1.801340] Call Trace: [ 1.801477] adf_vf_isr_resource_free+0x32/0xb0 [intel_qat] [ 1.801785] adf_vf_isr_resource_alloc+0x14d/0x150 [intel_qat] [ 1.802105] adf_dev_init+0xba/0x140 [intel_qat]
--- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/crypto/qat/qat_common/adf_vf_isr.c +13 -4
@@ -261,17 +261,26 @@ int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev) goto err_out;if (adf_setup_pf2vf_bh (accel_dev)) - goto err_out; + goto err_disable_msi;if (adf_setup_bh (accel_dev)) - goto err_out; + goto err_cleanup_pf2vf_bh;if (adf_request_msi_irq (accel_dev)) - goto err_out; + goto err_cleanup_bh;return 0 ; + +err_cleanup_bh: +adf_cleanup_bh (accel_dev); + +err_cleanup_pf2vf_bh: +adf_cleanup_pf2vf_bh (accel_dev); + +err_disable_msi: +adf_disable_msi (accel_dev); + err_out: -adf_vf_isr_resource_free (accel_dev);return -EFAULT ; }EXPORT_SYMBOL_GPL (adf_vf_isr_resource_alloc);
Signature · 1 line
2.25.1
PATCH v4 2/2 crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init
In reply to Giovanni CabidduADF_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]
--- 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(-)
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +2 -2
@@ -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;
drivers/crypto/qat/qat_c62xvf/adf_drv.c +2 -2
@@ -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;
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +2 -2
@@ -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;
Signature · 1 line
2.25.1
Re: [PATCH v4 2/2] crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init
Just a minor comment on the commit message:
crypto: qat: ADF_STATUS_PF_RUNNING ...
^
Patches to the qat driver have the following headline:
crypto: qat -
not
crypto: qat :
Regards,
Signature · 1 line
Giovanni
Quoted 85 lines · Tong Zhang
ADF_STATUS_PF_RUNNINGis (only) used and checked byadf_vf2pf_shutdown()before calling adf_iov_putmsg()->mutex_lock(vf2pf_lock), however thevf2pf_lockis initialized inadf_dev_init(), which can fail and when it fail, thevf2pf_lockis either not initialized or destroyed, a subsequent use ofvf2pf_lockwill cause issue.
To fix this issue, only set this flag ifadf_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 <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Fixes 25c6ffb249f6 ("crypto: qat - check if PF is running")Acked-by Giovanni Cabiddu <[email protected]>--- 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(-)drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +2
-2@@ -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;drivers/crypto/qat/qat_c62xvf/adf_drv.c +2
-2@@ -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;drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +2
-2@@ -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;Signature · 1 line
2.25.1
v5 cover crypto: qat - fix couple crashes duing error handling
There are a couple of issues in qat error handling. Those drivers tries to release resources that is not initialized. This patch series tries to fix crashes caused by incorrect error handling.
v2: removed excessive dump in commit log as suggested by Andy Shevchenko <[email protected]>
v3: collect tags as suggested by Andy Shevchenko <[email protected]>
v4: fix commit log typos
v5: fix headline
Tong Zhang (2):
crypto: qat - don't release uninitialized resources
crypto: qat - ADF_STATUS_PF_RUNNING should be set after adf_dev_init
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
PATCH v5 1/2 crypto: qat - don't release uninitialized resources
adf_vf_isr_resource_alloc() is not unwinding correctly when error happens and it want to release uninitialized resources. To fix this, only release initialized resources.
[ 1.792845] Trying to free already-free IRQ 11 [ 1.793091] WARNING: CPU: 0 PID: 182 at kernel/irq/manage.c:1821 free_irq+0x202/0x380 [ 1.801340] Call Trace: [ 1.801477] adf_vf_isr_resource_free+0x32/0xb0 [intel_qat] [ 1.801785] adf_vf_isr_resource_alloc+0x14d/0x150 [intel_qat] [ 1.802105] adf_dev_init+0xba/0x140 [intel_qat]
--- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/crypto/qat/qat_common/adf_vf_isr.c +13 -4
@@ -261,17 +261,26 @@ int adf_vf_isr_resource_alloc(struct adf_accel_dev *accel_dev) goto err_out;if (adf_setup_pf2vf_bh (accel_dev)) - goto err_out; + goto err_disable_msi;if (adf_setup_bh (accel_dev)) - goto err_out; + goto err_cleanup_pf2vf_bh;if (adf_request_msi_irq (accel_dev)) - goto err_out; + goto err_cleanup_bh;return 0 ; + +err_cleanup_bh: +adf_cleanup_bh (accel_dev); + +err_cleanup_pf2vf_bh: +adf_cleanup_pf2vf_bh (accel_dev); + +err_disable_msi: +adf_disable_msi (accel_dev); + err_out: -adf_vf_isr_resource_free (accel_dev);return -EFAULT ; }EXPORT_SYMBOL_GPL (adf_vf_isr_resource_alloc);
Signature · 1 line
2.25.1
PATCH v5 2/2 crypto: qat - ADF_STATUS_PF_RUNNING should be set after adf_dev_init
In reply to Tong ZhangADF_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]
--- 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(-)
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +2 -2
@@ -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;
drivers/crypto/qat/qat_c62xvf/adf_drv.c +2 -2
@@ -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;
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +2 -2
@@ -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;
Signature · 1 line
2.25.1
Herbert Xu
maintainerRe: [PATCH v5 0/2] crypto: qat - fix couple crashes duing error handling
In reply to Tong ZhangQuoted 13 lines · Tong Zhang
There are a couple of issues in qat error handling. Those drivers tries to release resources that is not initialized. This patch series tries to fix crashes caused by incorrect error handling.
v2: removed excessive dump in commit log as suggested by Andy Shevchenko <[email protected]>
v3: collect tags as suggested by Andy Shevchenko <[email protected]>
v4: fix commit log typos
v5: fix headlineTong Zhang (2):
crypto: qat - don't release uninitialized resources
crypto: qat -ADF_STATUS_PF_RUNNINGshould be set afteradf_dev_init
Quoted 5 lines
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_c62xvf/adf_drv.c | 4 ++-- drivers/crypto/qat/qat_common/adf_vf_isr.c | 17 +++++++++++++---- drivers/crypto/qat/qat_dh895xccvf/adf_drv.c | 4 ++-- 4 files changed, 19 insertions(+), 10 deletions(-)
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH v4 2/2] crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init
In reply to Giovanni CabidduThanks,
I fixed the headline and sent it as v5.
- Tong
Quoted 100 lines · Giovanni Cabiddu
Just a minor comment on the commit message:
crypto: qat:ADF_STATUS_PF_RUNNING...^Patches to the qat driver have the following headline:
crypto: qat -
not
crypto: qat :Regards,
--
GiovanniQuoted 85 lines · Tong Zhang
ADF_STATUS_PF_RUNNINGis (only) used and checked byadf_vf2pf_shutdown()before calling adf_iov_putmsg()->mutex_lock(vf2pf_lock), however thevf2pf_lockis initialized inadf_dev_init(), which can fail and when it fail, thevf2pf_lockis either not initialized or destroyed, a subsequent use ofvf2pf_lockwill cause issue.
To fix this issue, only set this flag ifadf_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 <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>Fixes 25c6ffb249f6 ("crypto: qat - check if PF is running")Acked-by Giovanni Cabiddu <[email protected]>--- 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(-)drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +2
-2@@ -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;drivers/crypto/qat/qat_c62xvf/adf_drv.c +2
-2@@ -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;drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +2
-3@@ -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
Re: [PATCH v3 1/2] crypto: qat - dont release uninitialized resources
In reply to Giovanni CabidduThanks!
I have fixed typos and resent them as v4.
- Tong
PATCH v3 2/2 crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init
In reply to Tong ZhangADF_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]
--- 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(-)
drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +2 -2
@@ -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;
drivers/crypto/qat/qat_c62xvf/adf_drv.c +2 -2
@@ -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;
drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +2 -2
@@ -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;
Signature · 1 line
2.25.1
Re: [PATCH v3 2/2] crypto: qat: ADF_STATUS_PF_RUNNING should be set after adf_dev_init
Quoted 15 lines · Tong Zhang
ADF_STATUS_PF_RUNNINGis (only) used and checked byadf_vf2pf_shutdown()before calling adf_iov_putmsg()->mutex_lock(vf2pf_lock), however thevf2pf_lockis initialized inadf_dev_init(), which can fail and when it fail, thevf2pf_lockis either not initialized or destroyed, a subsequent use ofvf2pf_lockwill cause issue.
To fix this issue, only set this flag ifadf_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]
Quoted 2 lines
Signed-off-by Tong Zhang <[email protected]>Reviewed-by Andy Shevchenko <[email protected]>
Quoted 66 lines
--- 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(-)drivers/crypto/qat/qat_c3xxxvf/adf_drv.c +2
-2@@ -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;drivers/crypto/qat/qat_c62xvf/adf_drv.c +2
-2@@ -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;drivers/crypto/qat/qat_dh895xccvf/adf_drv.c +2
-2@@ -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;Signature · 1 line
2.25.1