[dpdk-dev,v2] crypto/dpaa2_sec: add check for segmented buffer

Message ID 20171013153854.8444-1-alok.makhariya@nxp.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

alok.makhariya@nxp.com Oct. 13, 2017, 3:38 p.m. UTC
  From: Alok Makhariya <alok.makhariya@nxp.com>

The code would crash for segmented buffer if no check.

Fixes: 8d1f3a5d751b ("crypto/dpaa2_sec: support crypto operation")
Cc: stable@dpdk.org

Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
  

Comments

Akhil Goyal Oct. 13, 2017, 3:44 p.m. UTC | #1
On 10/13/2017 9:08 PM, alok.makhariya@nxp.com wrote:
> From: Alok Makhariya <alok.makhariya@nxp.com>
> 
> The code would crash for segmented buffer if no check.
> 
> Fixes: 8d1f3a5d751b ("crypto/dpaa2_sec: support crypto operation")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>
> ---
>   drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> index 672cacf..b33081c 100644
> --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> @@ -551,7 +551,13 @@ build_sec_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
>   	int ret = -1;
>   
>   	PMD_INIT_FUNC_TRACE();
> -
> +	/*
> +	 * Segmented buffer is not supported.
> +	 */
> +	if (!rte_pktmbuf_is_contiguous(op->sym->m_src)) {
> +		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
> +		return -ENOTSUP;
> +	}
>   	switch (sess->ctxt_type) {
>   	case DPAA2_SEC_CIPHER:
>   		ret = build_cipher_fd(sess, op, fd, bpid);
> 
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
  
De Lara Guarch, Pablo Oct. 16, 2017, 2:06 p.m. UTC | #2
> -----Original Message-----

> From: Akhil Goyal [mailto:akhil.goyal@nxp.com]

> Sent: Friday, October 13, 2017 4:45 PM

> To: alok.makhariya@nxp.com; dev@dpdk.org

> Cc: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>;

> hemant.agrawal@nxp.com; stable@dpdk.org

> Subject: Re: [PATCH v2] crypto/dpaa2_sec: add check for segmented buffer

> 

> On 10/13/2017 9:08 PM, alok.makhariya@nxp.com wrote:

> > From: Alok Makhariya <alok.makhariya@nxp.com>

> >

> > The code would crash for segmented buffer if no check.

> >

> > Fixes: 8d1f3a5d751b ("crypto/dpaa2_sec: support crypto operation")

> > Cc: stable@dpdk.org

> >

> > Signed-off-by: Alok Makhariya <alok.makhariya@nxp.com>

> > ---

> >   drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++++-

> >   1 file changed, 7 insertions(+), 1 deletion(-)

> >

> > diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c

> b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c

> > index 672cacf..b33081c 100644

> > --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c

> > +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c

> > @@ -551,7 +551,13 @@ build_sec_fd(dpaa2_sec_session *sess, struct

> rte_crypto_op *op,

> >   	int ret = -1;

> >

> >   	PMD_INIT_FUNC_TRACE();

> > -

> > +	/*

> > +	 * Segmented buffer is not supported.

> > +	 */

> > +	if (!rte_pktmbuf_is_contiguous(op->sym->m_src)) {

> > +		op->status = RTE_CRYPTO_OP_STATUS_ERROR;

> > +		return -ENOTSUP;

> > +	}

> >   	switch (sess->ctxt_type) {

> >   	case DPAA2_SEC_CIPHER:

> >   		ret = build_cipher_fd(sess, op, fd, bpid);

> >

> Acked-by: Akhil Goyal <akhil.goyal@nxp.com>


Applied to dpdk-next-crypto.
Thanks,

Pablo
  

Patch

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 672cacf..b33081c 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -551,7 +551,13 @@  build_sec_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
 	int ret = -1;
 
 	PMD_INIT_FUNC_TRACE();
-
+	/*
+	 * Segmented buffer is not supported.
+	 */
+	if (!rte_pktmbuf_is_contiguous(op->sym->m_src)) {
+		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
+		return -ENOTSUP;
+	}
 	switch (sess->ctxt_type) {
 	case DPAA2_SEC_CIPHER:
 		ret = build_cipher_fd(sess, op, fd, bpid);