[dpdk-dev] crypto/aesni_mb: fix possible crypto job leak

Message ID 20170713033512.25123-1-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Pablo de Lara Guarch
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

De Lara Guarch, Pablo July 13, 2017, 3:35 a.m. UTC
  When dequeueing operations from an AESNI-MB device,
crypto jobs are dequeued from the internal scheduler
in the Multi-buffer library.

If the number of jobs available to retrieve
are higher than the number of crypto operations
that are required, then an extra job is retrieved
(due to an incorrect conditional), but not used.
This leads to a job leak and the operation associated
to that job will not be ever dequeued.

Fixes: 0f548b50a160 ("crypto/aesni_mb: process crypto op on dequeue")
Cc: stable@dpdk.org

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Doherty, Declan July 13, 2017, 3:56 p.m. UTC | #1
On 13/07/2017 4:35 AM, Pablo de Lara wrote:
> When dequeueing operations from an AESNI-MB device,
> crypto jobs are dequeued from the internal scheduler
> in the Multi-buffer library.
>
> If the number of jobs available to retrieve
> are higher than the number of crypto operations
> that are required, then an extra job is retrieved
> (due to an incorrect conditional), but not used.
> This leads to a job leak and the operation associated
> to that job will not be ever dequeued.
>
> Fixes: 0f548b50a160 ("crypto/aesni_mb: process crypto op on dequeue")
> Cc: stable@dpdk.org
>
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> ---

...
>

Acked-by: Declan Doherty <declan.doherty@intel.com>
  
De Lara Guarch, Pablo July 13, 2017, 4:34 p.m. UTC | #2
> -----Original Message-----
> From: Doherty, Declan
> Sent: Thursday, July 13, 2017 4:56 PM
> To: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: Re: [PATCH] crypto/aesni_mb: fix possible crypto job leak
> 
> On 13/07/2017 4:35 AM, Pablo de Lara wrote:
> > When dequeueing operations from an AESNI-MB device, crypto jobs are
> > dequeued from the internal scheduler in the Multi-buffer library.
> >
> > If the number of jobs available to retrieve are higher than the number
> > of crypto operations that are required, then an extra job is retrieved
> > (due to an incorrect conditional), but not used.
> > This leads to a job leak and the operation associated to that job will
> > not be ever dequeued.
> >
> > Fixes: 0f548b50a160 ("crypto/aesni_mb: process crypto op on dequeue")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
> > ---
> 
> ...
> >
> 
> Acked-by: Declan Doherty <declan.doherty@intel.com>

Applied to dpdk-next-crypto.

Pablo
  

Patch

diff --git a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
index 3aaa070..13cffaf 100644
--- a/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
+++ b/drivers/crypto/aesni_mb/rte_aesni_mb_pmd.c
@@ -587,7 +587,7 @@  handle_completed_jobs(struct aesni_mb_qp *qp, JOB_AES_HMAC *job,
 	struct rte_crypto_op *op = NULL;
 	unsigned processed_jobs = 0;
 
-	while (job != NULL && processed_jobs < nb_ops) {
+	while (job != NULL) {
 		op = post_process_mb_job(qp, job);
 
 		if (op) {
@@ -597,6 +597,8 @@  handle_completed_jobs(struct aesni_mb_qp *qp, JOB_AES_HMAC *job,
 			qp->stats.dequeue_err_count++;
 			break;
 		}
+		if (processed_jobs == nb_ops)
+			break;
 
 		job = (*qp->op_fns->job.get_completed_job)(&qp->mb_mgr);
 	}