DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] compress/qat: fix build issue with clang 7.0.0
@ 2018-10-27 16:48 Jerin Jacob
  2018-10-29 17:29 ` Trahe, Fiona
  2018-10-31  0:39 ` [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error Fiona Trahe
  0 siblings, 2 replies; 7+ messages in thread
From: Jerin Jacob @ 2018-10-27 16:48 UTC (permalink / raw)
  To: dev, Fiona Trahe, Pablo de Lara, Gupta, Ashish; +Cc: thomas, Jacob,  Jerin

QAT_NUM_BUFS_IN_IM_SGL defined as 1 the code access beyond
the first element.

error log:
/export/dpdk.org/drivers/compress/qat/qat_comp_pmd.c:214:3:
error: array index 1 is past the end of the array
(which contains 1 element) [-Werror,-Warray-bounds]
sgl->buffers[1].addr = mz_start_phys + offset_of_flat_buffs +

Fixes: a124830a6f00 ("compress/qat: enable dynamic huffman encoding")

Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
 drivers/compress/qat/qat_comp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/compress/qat/qat_comp.h b/drivers/compress/qat/qat_comp.h
index 99a4462eb..24d0d9cb4 100644
--- a/drivers/compress/qat/qat_comp.h
+++ b/drivers/compress/qat/qat_comp.h
@@ -17,7 +17,7 @@
 
 #define QAT_64_BYTE_ALIGN_MASK (~0x3f)
 #define QAT_64_BYTE_ALIGN (64)
-#define QAT_NUM_BUFS_IN_IM_SGL 1
+#define QAT_NUM_BUFS_IN_IM_SGL 2
 
 #define ERR_CODE_QAT_COMP_WRONG_FW -99
 
-- 
2.19.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] compress/qat: fix build issue with clang 7.0.0
  2018-10-27 16:48 [dpdk-dev] [PATCH] compress/qat: fix build issue with clang 7.0.0 Jerin Jacob
@ 2018-10-29 17:29 ` Trahe, Fiona
  2018-10-31  0:39 ` [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error Fiona Trahe
  1 sibling, 0 replies; 7+ messages in thread
From: Trahe, Fiona @ 2018-10-29 17:29 UTC (permalink / raw)
  To: Jerin Jacob, dev, Gupta, Ashish; +Cc: thomas, Jacob,  Jerin, Trahe, Fiona

Hi Jerin,

> -----Original Message-----
> From: Jerin Jacob [mailto:jerin.jacob@caviumnetworks.com]
> Sent: Saturday, October 27, 2018 9:48 AM
> To: dev@dpdk.org; Trahe, Fiona <fiona.trahe@intel.com>; De Lara Guarch, Pablo
> <pablo.de.lara.guarch@intel.com>; Gupta, Ashish <Ashish.Gupta@cavium.com>
> Cc: thomas@monjalon.net; Jacob, Jerin <Jerin.JacobKollanukkaran@cavium.com>
> Subject: [dpdk-dev] [PATCH] compress/qat: fix build issue with clang 7.0.0
> 
> QAT_NUM_BUFS_IN_IM_SGL defined as 1 the code access beyond
> the first element.
> 
> error log:
> /export/dpdk.org/drivers/compress/qat/qat_comp_pmd.c:214:3:
> error: array index 1 is past the end of the array
> (which contains 1 element) [-Werror,-Warray-bounds]
> sgl->buffers[1].addr = mz_start_phys + offset_of_flat_buffs +
> 
> Fixes: a124830a6f00 ("compress/qat: enable dynamic huffman encoding")
> 
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  drivers/compress/qat/qat_comp.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/compress/qat/qat_comp.h b/drivers/compress/qat/qat_comp.h
> index 99a4462eb..24d0d9cb4 100644
> --- a/drivers/compress/qat/qat_comp.h
> +++ b/drivers/compress/qat/qat_comp.h
> @@ -17,7 +17,7 @@
> 
>  #define QAT_64_BYTE_ALIGN_MASK (~0x3f)
>  #define QAT_64_BYTE_ALIGN (64)
> -#define QAT_NUM_BUFS_IN_IM_SGL 1
> +#define QAT_NUM_BUFS_IN_IM_SGL 2
[Fiona] Thanks for this. I'm surprised gcc didn't give a warning.
However, setting to 2 causes issues on some platforms, which 
was why we reverted to 1 in an earlier iteration.
So Nack
I'll send a different patch to fix.

> 
>  #define ERR_CODE_QAT_COMP_WRONG_FW -99
> 
> --
> 2.19.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error
  2018-10-27 16:48 [dpdk-dev] [PATCH] compress/qat: fix build issue with clang 7.0.0 Jerin Jacob
  2018-10-29 17:29 ` Trahe, Fiona
@ 2018-10-31  0:39 ` Fiona Trahe
  2018-10-31  6:35   ` Jerin Jacob
  2018-11-01 21:16   ` Jozwiak, TomaszX
  1 sibling, 2 replies; 7+ messages in thread
From: Fiona Trahe @ 2018-10-31  0:39 UTC (permalink / raw)
  To: dev; +Cc: thomas, akhil.goyal, tomaszx.jozwiak, jerin.jacob, Fiona Trahe

QAT array for sgls in intermediate buffer structure
was #defined to 1, but setup code hardcoded as if 2 buffers
so causing out of bounds write. Reworked to loop correctly
using #define.

Fixes: a124830a6f00 ("compress/qat: enable dynamic huffman encoding")

Reported-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
---
 drivers/compress/qat/qat_comp_pmd.c | 38 ++++++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/compress/qat/qat_comp_pmd.c b/drivers/compress/qat/qat_comp_pmd.c
index 01dd736..ea93077 100644
--- a/drivers/compress/qat/qat_comp_pmd.c
+++ b/drivers/compress/qat/qat_comp_pmd.c
@@ -165,11 +165,14 @@ qat_comp_setup_inter_buffers(struct qat_comp_dev_private *comp_dev,
 	}
 
 	/* Create a memzone to hold intermediate buffers and associated
-	 * meta-data needed by the firmware. The memzone contains:
+	 * meta-data needed by the firmware. The memzone contains 3 parts:
 	 *  - a list of num_im_sgls physical pointers to sgls
-	 *  - the num_im_sgl sgl structures, each pointing to 2 flat buffers
-	 *  - the flat buffers: num_im_sgl * 2
-	 * where num_im_sgls depends on the hardware generation of the device
+	 *  - the num_im_sgl sgl structures, each pointing to
+	 *    QAT_NUM_BUFS_IN_IM_SGL flat buffers
+	 *  - the flat buffers: num_im_sgl * QAT_NUM_BUFS_IN_IM_SGL
+	 *    buffers, each of buff_size
+	 * num_im_sgls depends on the hardware generation of the device
+	 * buff_size comes from the user via the config file
 	 */
 
 	size_of_ptr_array = num_im_sgls * sizeof(phys_addr_t);
@@ -202,30 +205,31 @@ qat_comp_setup_inter_buffers(struct qat_comp_dev_private *comp_dev,
 		    offset_of_sgls + i * sizeof(struct qat_inter_sgl);
 		struct qat_inter_sgl *sgl =
 		    (struct qat_inter_sgl *)(mz_start +	curr_sgl_offset);
+		int lb;
 		array_of_pointers->pointer[i] = mz_start_phys + curr_sgl_offset;
 
 		sgl->num_bufs = QAT_NUM_BUFS_IN_IM_SGL;
 		sgl->num_mapped_bufs = 0;
 		sgl->resrvd = 0;
-		sgl->buffers[0].addr = mz_start_phys + offset_of_flat_buffs +
-			((i * QAT_NUM_BUFS_IN_IM_SGL) * buff_size);
-		sgl->buffers[0].len = buff_size;
-		sgl->buffers[0].resrvd = 0;
-		sgl->buffers[1].addr = mz_start_phys + offset_of_flat_buffs +
-			(((i * QAT_NUM_BUFS_IN_IM_SGL) + 1) * buff_size);
-		sgl->buffers[1].len = buff_size;
-		sgl->buffers[1].resrvd = 0;
 
 #if QAT_IM_BUFFER_DEBUG
 		QAT_LOG(DEBUG, "  : phys addr of sgl[%i] in array_of_pointers"
-			    "= 0x%"PRIx64, i, array_of_pointers->pointer[i]);
+			" = 0x%"PRIx64, i, array_of_pointers->pointer[i]);
 		QAT_LOG(DEBUG, "  : virt address of sgl[%i] = %p", i, sgl);
-		QAT_LOG(DEBUG, "  : sgl->buffers[0].addr = 0x%"PRIx64", len=%d",
-			sgl->buffers[0].addr, sgl->buffers[0].len);
-		QAT_LOG(DEBUG, "  : sgl->buffers[1].addr = 0x%"PRIx64", len=%d",
-			sgl->buffers[1].addr, sgl->buffers[1].len);
+#endif
+		for (lb = 0; lb < QAT_NUM_BUFS_IN_IM_SGL; lb++) {
+			sgl->buffers[lb].addr =
+			  mz_start_phys + offset_of_flat_buffs +
+			  (((i * QAT_NUM_BUFS_IN_IM_SGL) + lb) * buff_size);
+			sgl->buffers[lb].len = buff_size;
+			sgl->buffers[lb].resrvd = 0;
+#if QAT_IM_BUFFER_DEBUG
+			QAT_LOG(DEBUG,
+			  "  : sgl->buffers[%d].addr = 0x%"PRIx64", len=%d",
+			  lb, sgl->buffers[lb].addr, sgl->buffers[lb].len);
 #endif
 		}
+	}
 #if QAT_IM_BUFFER_DEBUG
 	QAT_DP_HEXDUMP_LOG(DEBUG,  "IM buffer memzone start:",
 			mz_start, offset_of_flat_buffs + 32);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error
  2018-10-31  0:39 ` [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error Fiona Trahe
@ 2018-10-31  6:35   ` Jerin Jacob
  2018-11-01 14:16     ` Bruce Richardson
  2018-11-01 21:16   ` Jozwiak, TomaszX
  1 sibling, 1 reply; 7+ messages in thread
From: Jerin Jacob @ 2018-10-31  6:35 UTC (permalink / raw)
  To: Fiona Trahe; +Cc: dev, thomas, akhil.goyal, tomaszx.jozwiak

-----Original Message-----
> Date: Wed, 31 Oct 2018 00:39:54 +0000
> From: Fiona Trahe <fiona.trahe@intel.com>
> To: dev@dpdk.org
> CC: thomas@monjalon.net, akhil.goyal@nxp.com, tomaszx.jozwiak@intel.com,
>  jerin.jacob@caviumnetworks.com, Fiona Trahe <fiona.trahe@intel.com>
> Subject: [PATCH] compress/qat: fix out-of-bounds error
> X-Mailer: git-send-email 1.7.0.7
> 
> 
> QAT array for sgls in intermediate buffer structure
> was #defined to 1, but setup code hardcoded as if 2 buffers
> so causing out of bounds write. Reworked to loop correctly
> using #define.
> 
> Fixes: a124830a6f00 ("compress/qat: enable dynamic huffman encoding")
> 
> Reported-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>

clang build is not reproducible with this patch.

Tested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error
  2018-10-31  6:35   ` Jerin Jacob
@ 2018-11-01 14:16     ` Bruce Richardson
  2018-11-02 11:41       ` Akhil Goyal
  0 siblings, 1 reply; 7+ messages in thread
From: Bruce Richardson @ 2018-11-01 14:16 UTC (permalink / raw)
  To: Jerin Jacob; +Cc: Fiona Trahe, dev, thomas, akhil.goyal, tomaszx.jozwiak

On Wed, Oct 31, 2018 at 06:35:11AM +0000, Jerin Jacob wrote:
> -----Original Message-----
> > Date: Wed, 31 Oct 2018 00:39:54 +0000
> > From: Fiona Trahe <fiona.trahe@intel.com>
> > To: dev@dpdk.org
> > CC: thomas@monjalon.net, akhil.goyal@nxp.com, tomaszx.jozwiak@intel.com,
> >  jerin.jacob@caviumnetworks.com, Fiona Trahe <fiona.trahe@intel.com>
> > Subject: [PATCH] compress/qat: fix out-of-bounds error
> > X-Mailer: git-send-email 1.7.0.7
> > 
> > 
> > QAT array for sgls in intermediate buffer structure
> > was #defined to 1, but setup code hardcoded as if 2 buffers
> > so causing out of bounds write. Reworked to loop correctly
> > using #define.
> > 
> > Fixes: a124830a6f00 ("compress/qat: enable dynamic huffman encoding")
> > 
> > Reported-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> > Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
> 
> clang build is not reproducible with this patch.

s/not/now/ :-)
> 
> Tested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> 

I can also confirm that clang builds which were failing without this patch
are now building ok on Fedora 29.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error
  2018-10-31  0:39 ` [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error Fiona Trahe
  2018-10-31  6:35   ` Jerin Jacob
@ 2018-11-01 21:16   ` Jozwiak, TomaszX
  1 sibling, 0 replies; 7+ messages in thread
From: Jozwiak, TomaszX @ 2018-11-01 21:16 UTC (permalink / raw)
  To: Trahe, Fiona, dev; +Cc: thomas, akhil.goyal, jerin.jacob



> -----Original Message-----
> From: Trahe, Fiona
> Sent: Wednesday, October 31, 2018 1:40 AM
> To: dev@dpdk.org
> Cc: thomas@monjalon.net; akhil.goyal@nxp.com; Jozwiak, TomaszX
> <tomaszx.jozwiak@intel.com>; jerin.jacob@caviumnetworks.com; Trahe,
> Fiona <fiona.trahe@intel.com>
> Subject: [PATCH] compress/qat: fix out-of-bounds error
> 
> QAT array for sgls in intermediate buffer structure was #defined to 1, but
> setup code hardcoded as if 2 buffers so causing out of bounds write.
> Reworked to loop correctly using #define.
> 
> Fixes: a124830a6f00 ("compress/qat: enable dynamic huffman encoding")
> 
> Reported-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
> ---

Acked-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error
  2018-11-01 14:16     ` Bruce Richardson
@ 2018-11-02 11:41       ` Akhil Goyal
  0 siblings, 0 replies; 7+ messages in thread
From: Akhil Goyal @ 2018-11-02 11:41 UTC (permalink / raw)
  To: Bruce Richardson, Jerin Jacob; +Cc: Fiona Trahe, dev, thomas, tomaszx.jozwiak



On 11/1/2018 7:46 PM, Bruce Richardson wrote:
> On Wed, Oct 31, 2018 at 06:35:11AM +0000, Jerin Jacob wrote:
>> -----Original Message-----
>>> Date: Wed, 31 Oct 2018 00:39:54 +0000
>>> From: Fiona Trahe <fiona.trahe@intel.com>
>>> To: dev@dpdk.org
>>> CC: thomas@monjalon.net, akhil.goyal@nxp.com, tomaszx.jozwiak@intel.com,
>>>   jerin.jacob@caviumnetworks.com, Fiona Trahe <fiona.trahe@intel.com>
>>> Subject: [PATCH] compress/qat: fix out-of-bounds error
>>> X-Mailer: git-send-email 1.7.0.7
>>>
>>>
>>> QAT array for sgls in intermediate buffer structure
>>> was #defined to 1, but setup code hardcoded as if 2 buffers
>>> so causing out of bounds write. Reworked to loop correctly
>>> using #define.
>>>
>>> Fixes: a124830a6f00 ("compress/qat: enable dynamic huffman encoding")
>>>
>>> Reported-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>>> Signed-off-by: Fiona Trahe <fiona.trahe@intel.com>
>> clang build is not reproducible with this patch.
> s/not/now/ :-)
>> Tested-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
>>
> I can also confirm that clang builds which were failing without this patch
> are now building ok on Fedora 29.
>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
Applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-11-02 11:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-27 16:48 [dpdk-dev] [PATCH] compress/qat: fix build issue with clang 7.0.0 Jerin Jacob
2018-10-29 17:29 ` Trahe, Fiona
2018-10-31  0:39 ` [dpdk-dev] [PATCH] compress/qat: fix out-of-bounds error Fiona Trahe
2018-10-31  6:35   ` Jerin Jacob
2018-11-01 14:16     ` Bruce Richardson
2018-11-02 11:41       ` Akhil Goyal
2018-11-01 21:16   ` Jozwiak, TomaszX

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).