DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs
@ 2018-05-09  1:30 Andy Green
  2018-05-09  1:30 ` [dpdk-dev] [PATCH v2 01/18] lib/libtre_table: workaround hash function cast error Andy Green
                   ` (17 more replies)
  0 siblings, 18 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:30 UTC (permalink / raw)
  To: dev

The following series gets current master able to build
on Fedora 28 + x86_64 using gcc 8.0.1.  There were a surprising
number of problems, mostly around correct string processing.

Of the two major issues, one around struct alignment in
dpaa I think is properly fixed by the patch 3/18 here,
but for the apparently broken hash function cast in 1/18
I just stopped it breaking the build.  It seems others are
working on a proper solution for it.

This version of the series incorporates comments from the list
and replaces the broken strncpy() with strlcpy(), adding the
necessary include as needed.

---

Andy Green (18):
      lib/libtre_table: workaround hash function cast error
      drivers/bus/pci: fix strncpy dangerous code
      drivers/bus/dpaa: fix inconsistent struct alignment
      drivers/net/axgbe: fix broken eeprom string comp
      drivers/net/nfp/nfpcore: fix strncpy misuse
      drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use
      drivers/net/nfp: don't memcpy out of source range
      drivers/net/nfp: fix buffer overflow in fw_name
      drivers/net/qede: fix strncpy constant and NUL
      drivers/net/qede: fix broken strncpy
      drivers/net/sfc: fix strncpy length
      drivers/net/sfc: fix strncpy size and NUL
      drivers/net/vdev: readlink inputs cannot be aliased
      drivers/net/vdev: fix 3 x strncpy misuse
      app/test-pmd: can't find include
      app/proc-info: fix sprintf overrun bug
      app/test-bbdev: test-bbdev: strcpy ok for allocated string
      app/test-bbdev: strcpy ok for allocated string


 app/proc-info/main.c                       |    9 +++++++--
 app/test-bbdev/test_bbdev_vector.c         |    5 +++--
 app/test-pmd/Makefile                      |    1 +
 drivers/bus/dpaa/base/qbman/qman.c         |   14 +++++++-------
 drivers/bus/dpaa/include/fsl_qman.h        |   24 +++++++++++++-----------
 drivers/bus/pci/linux/pci.c                |    2 +-
 drivers/net/axgbe/axgbe_phy_impl.c         |    4 ++--
 drivers/net/nfp/nfp_net.c                  |    4 ++--
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c |    4 +++-
 drivers/net/nfp/nfpcore/nfp_resource.c     |    8 +++++---
 drivers/net/qede/base/ecore_int.c          |    8 +++++---
 drivers/net/qede/qede_main.c               |    7 ++++---
 drivers/net/sfc/sfc_ethdev.c               |    6 +++---
 drivers/net/vdev_netvsc/vdev_netvsc.c      |   15 +++++++++------
 lib/librte_table/rte_table_hash_cuckoo.c   |    2 +-
 15 files changed, 66 insertions(+), 47 deletions(-)

--
Signature

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

* [dpdk-dev] [PATCH v2 01/18] lib/libtre_table: workaround hash function cast error
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
@ 2018-05-09  1:30 ` Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 02/18] drivers/bus/pci: fix strncpy dangerous code Andy Green
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:30 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/lib/librte_table/rte_table_hash_cuckoo.c:
110:16: error: cast between incompatible function types from
‘rte_table_hash_op_hash’ {aka ‘long unsigned int (*)(void *, void *,
unsigned int,  long unsigned int)’} to ‘uint32_t (*)(const void *,
uint32_t,  uint32_t)’ {aka ‘unsigned int (*)(const void *, unsigned
int,  unsigned int)’} [-Werror=cast-function-type]   .hash_func =
(rte_hash_function)(p->f_hash),

The code seems to be quite broken.

It's casting this

typedef uint64_t (*rte_table_hash_op_hash)(
        void *key,
        void *key_mask,
        uint32_t key_size,
        uint64_t seed);

to this

typedef uint32_t (*rte_hash_function)(const void *key, uint32_t key_len,
                                      uint32_t init_val);

if the definition with 4 args is later called with a pointer
giving it three args, obviously it working is just an accident.  I
grepped around a bit and could not see it being cast back to
the original type before use; the uses I saw have three args.

I simply patch it to stop the build breaking, rather than fix it,
since I am not sure what a fix should look like considering the
whole code.

(It seems others are working on fixing this, so you probably don't
want to apply this.  However it's necessary for build to continue atm)

Signed-off-by: Andy Green <andy@warmcat.com>
---
 lib/librte_table/rte_table_hash_cuckoo.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_table/rte_table_hash_cuckoo.c b/lib/librte_table/rte_table_hash_cuckoo.c
index dcb4fe978..eca72b506 100644
--- a/lib/librte_table/rte_table_hash_cuckoo.c
+++ b/lib/librte_table/rte_table_hash_cuckoo.c
@@ -107,7 +107,7 @@ rte_table_hash_cuckoo_create(void *params,
 	struct rte_hash_parameters hash_cuckoo_params = {
 		.entries = p->n_keys,
 		.key_len = p->key_size,
-		.hash_func = (rte_hash_function)(p->f_hash),
+		.hash_func = (rte_hash_function)(void *)(p->f_hash),
 		.hash_func_init_val = p->seed,
 		.socket_id = socket_id,
 		.name = p->name

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

* [dpdk-dev] [PATCH v2 02/18] drivers/bus/pci: fix strncpy dangerous code
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
  2018-05-09  1:30 ` [dpdk-dev] [PATCH v2 01/18] lib/libtre_table: workaround hash function cast error Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 03/18] drivers/bus/dpaa: fix inconsistent struct alignment Andy Green
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

In function ‘pci_get_kernel_driver_by_path’,
    inlined from ‘pci_scan_one.isra.1’ at /home/agreen/projects/dpdk/
	drivers/bus/pci/linux/pci.c:317:8:
/home/agreen/projects/dpdk/drivers/bus/pci/linux/pci.c:57:3: error:
‘strncpy’ specified bound depends on the length of the source argument
[-Werror=stringop-overflow=]
   strncpy(dri_name, name + 1, strlen(name + 1) + 1);

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/bus/pci/linux/pci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index 4630a8057..a73ee49c2 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -54,7 +54,7 @@ pci_get_kernel_driver_by_path(const char *filename, char *dri_name)
 
 	name = strrchr(path, '/');
 	if (name) {
-		strncpy(dri_name, name + 1, strlen(name + 1) + 1);
+		strlcpy(dri_name, name + 1, sizeof(dri_name));
 		return 0;
 	}
 

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

* [dpdk-dev] [PATCH v2 03/18] drivers/bus/dpaa: fix inconsistent struct alignment
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
  2018-05-09  1:30 ` [dpdk-dev] [PATCH v2 01/18] lib/libtre_table: workaround hash function cast error Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 02/18] drivers/bus/pci: fix strncpy dangerous code Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  8:06   ` Hemant Agrawal
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 04/18] drivers/net/axgbe: fix broken eeprom string comp Andy Green
                   ` (14 subsequent siblings)
  17 siblings, 1 reply; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

The actual descriptor for qm_mr_entry is 64-byte aligned.

But the original code plays a trick, and puts a u8 common
to the three descriptor subtypes in the union afterwards
outside their structure definitions.

Unfortunately since they compose a struct qm_fd with
alignment 8, this trick destroys the ability of the compiler
to understand what has happened, resulting in this kind of
problem:

/home/agreen/projects/dpdk/drivers/bus/dpaa/include/
fsl_qman.h:354:3: error: alignment 1 of ‘struct <anonymous>’
is less than 8 [-Werror=packed-not-aligned]
   } __packed dcern;

on gcc 8 / Fedora 28 out of the box.

This patch moves the u8 verb into the structure definitions
composed into the union, so the alignment of the parent struct
containing the alignment 8 object can also be seen to be
alignment 8 by the compiler.  Uses of .verb are fixed up to use
.ern.verb (the same offset of +0 inside all the structs in
the union).

The final struct layout should be unchanged.

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/bus/dpaa/base/qbman/qman.c  |   14 +++++++-------
 drivers/bus/dpaa/include/fsl_qman.h |   24 +++++++++++++-----------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c
index 2810fdd26..27d98cc10 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -314,9 +314,9 @@ static int drain_mr_fqrni(struct qm_portal *p)
 		if (!msg)
 			return 0;
 	}
-	if ((msg->verb & QM_MR_VERB_TYPE_MASK) != QM_MR_VERB_FQRNI) {
+	if ((msg->ern.verb & QM_MR_VERB_TYPE_MASK) != QM_MR_VERB_FQRNI) {
 		/* We aren't draining anything but FQRNIs */
-		pr_err("Found verb 0x%x in MR\n", msg->verb);
+		pr_err("Found verb 0x%x in MR\n", msg->ern.verb);
 		return -1;
 	}
 	qm_mr_next(p);
@@ -483,7 +483,7 @@ static inline void qm_mr_pvb_update(struct qm_portal *portal)
 	/* when accessing 'verb', use __raw_readb() to ensure that compiler
 	 * inlining doesn't try to optimise out "excess reads".
 	 */
-	if ((__raw_readb(&res->verb) & QM_MR_VERB_VBIT) == mr->vbit) {
+	if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
 		mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
 		if (!mr->pi)
 			mr->vbit ^= QM_MR_VERB_VBIT;
@@ -832,7 +832,7 @@ static u32 __poll_portal_slow(struct qman_portal *p, u32 is)
 			goto mr_done;
 		swapped_msg = *msg;
 		hw_fd_to_cpu(&swapped_msg.ern.fd);
-		verb = msg->verb & QM_MR_VERB_TYPE_MASK;
+		verb = msg->ern.verb & QM_MR_VERB_TYPE_MASK;
 		/* The message is a software ERN iff the 0x20 bit is set */
 		if (verb & 0x20) {
 			switch (verb) {
@@ -1666,7 +1666,7 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
 			 */
 			struct qm_mr_entry msg;
 
-			msg.verb = QM_MR_VERB_FQRNI;
+			msg.ern.verb = QM_MR_VERB_FQRNI;
 			msg.fq.fqs = mcr->alterfq.fqs;
 			msg.fq.fqid = fq->fqid;
 #ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
@@ -2643,7 +2643,7 @@ int qman_shutdown_fq(u32 fqid)
 				qm_mr_pvb_update(low_p);
 				msg = qm_mr_current(low_p);
 				while (msg) {
-					if ((msg->verb &
+					if ((msg->ern.verb &
 					     QM_MR_VERB_TYPE_MASK)
 					    == QM_MR_VERB_FQRN)
 						found_fqrn = 1;
@@ -2711,7 +2711,7 @@ int qman_shutdown_fq(u32 fqid)
 			qm_mr_pvb_update(low_p);
 			msg = qm_mr_current(low_p);
 			while (msg) {
-				if ((msg->verb & QM_MR_VERB_TYPE_MASK) ==
+				if ((msg->ern.verb & QM_MR_VERB_TYPE_MASK) ==
 				    QM_MR_VERB_FQRL)
 					orl_empty = 1;
 				qm_mr_next(low_p);
diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index e9793f30d..e4ad7ae48 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -284,20 +284,20 @@ static inline dma_addr_t qm_sg_addr(const struct qm_sg_entry *sg)
 	} while (0)
 
 /* See 1.5.8.1: "Enqueue Command" */
-struct qm_eqcr_entry {
+struct __rte_aligned(8) qm_eqcr_entry {
 	u8 __dont_write_directly__verb;
 	u8 dca;
 	u16 seqnum;
 	u32 orp;	/* 24-bit */
 	u32 fqid;	/* 24-bit */
 	u32 tag;
-	struct qm_fd fd;
+	struct qm_fd fd; /* this has alignment 8 */
 	u8 __reserved3[32];
 } __packed;
 
 
 /* "Frame Dequeue Response" */
-struct qm_dqrr_entry {
+struct __rte_aligned(8) qm_dqrr_entry {
 	u8 verb;
 	u8 stat;
 	u16 seqnum;	/* 15-bit */
@@ -305,7 +305,7 @@ struct qm_dqrr_entry {
 	u8 __reserved2[3];
 	u32 fqid;	/* 24-bit */
 	u32 contextB;
-	struct qm_fd fd;
+	struct qm_fd fd; /* this has alignment 8 */
 	u8 __reserved4[32];
 };
 
@@ -323,18 +323,19 @@ struct qm_dqrr_entry {
 /* "ERN Message Response" */
 /* "FQ State Change Notification" */
 struct qm_mr_entry {
-	u8 verb;
 	union {
 		struct {
+			u8 verb;
 			u8 dca;
 			u16 seqnum;
 			u8 rc;		/* Rejection Code */
 			u32 orp:24;
 			u32 fqid;	/* 24-bit */
 			u32 tag;
-			struct qm_fd fd;
-		} __packed ern;
+			struct qm_fd fd; /* this has alignment 8 */
+		} __packed __rte_aligned(8) ern;
 		struct {
+			u8 verb;
 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 			u8 colour:2;	/* See QM_MR_DCERN_COLOUR_* */
 			u8 __reserved1:4;
@@ -349,18 +350,19 @@ struct qm_mr_entry {
 			u32 __reserved3:24;
 			u32 fqid;	/* 24-bit */
 			u32 tag;
-			struct qm_fd fd;
-		} __packed dcern;
+			struct qm_fd fd; /* this has alignment 8 */
+		} __packed __rte_aligned(8) dcern;
 		struct {
+			u8 verb;
 			u8 fqs;		/* Frame Queue Status */
 			u8 __reserved1[6];
 			u32 fqid;	/* 24-bit */
 			u32 contextB;
 			u8 __reserved2[16];
-		} __packed fq;		/* FQRN/FQRNI/FQRL/FQPN */
+		} __packed __rte_aligned(8) fq;	/* FQRN/FQRNI/FQRL/FQPN */
 	};
 	u8 __reserved2[32];
-} __packed;
+} __packed __rte_aligned(8);
 #define QM_MR_VERB_VBIT			0x80
 /*
  * ERNs originating from direct-connect portals ("dcern") use 0x20 as a verb

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

* [dpdk-dev] [PATCH v2 04/18] drivers/net/axgbe: fix broken eeprom string comp
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (2 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 03/18] drivers/bus/dpaa: fix inconsistent struct alignment Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 05/18] drivers/net/nfp/nfpcore: fix strncpy misuse Andy Green
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/drivers/net/axgbe/axgbe_phy_impl.c:576:6:
error: ‘__builtin_memcmp_eq’ reading 16 bytes from a region of
size 9 [-Werror=stringop-overflow=]
  if (memcmp(&sfp_eeprom->base[AXGBE_SFP_BASE_VENDOR_NAME],
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      AXGBE_BEL_FUSE_VENDOR, AXGBE_SFP_BASE_VENDOR_NAME_LEN))

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/axgbe/axgbe_phy_impl.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_phy_impl.c b/drivers/net/axgbe/axgbe_phy_impl.c
index dfa908dd8..973177f69 100644
--- a/drivers/net/axgbe/axgbe_phy_impl.c
+++ b/drivers/net/axgbe/axgbe_phy_impl.c
@@ -574,11 +574,11 @@ static bool axgbe_phy_belfuse_parse_quirks(struct axgbe_port *pdata)
 	struct axgbe_sfp_eeprom *sfp_eeprom = &phy_data->sfp_eeprom;
 
 	if (memcmp(&sfp_eeprom->base[AXGBE_SFP_BASE_VENDOR_NAME],
-		   AXGBE_BEL_FUSE_VENDOR, AXGBE_SFP_BASE_VENDOR_NAME_LEN))
+		   AXGBE_BEL_FUSE_VENDOR, strlen(AXGBE_BEL_FUSE_VENDOR)))
 		return false;
 
 	if (!memcmp(&sfp_eeprom->base[AXGBE_SFP_BASE_VENDOR_PN],
-		    AXGBE_BEL_FUSE_PARTNO, AXGBE_SFP_BASE_VENDOR_PN_LEN)) {
+		    AXGBE_BEL_FUSE_PARTNO, strlen(AXGBE_BEL_FUSE_PARTNO))) {
 		phy_data->sfp_base = AXGBE_SFP_BASE_1000_SX;
 		phy_data->sfp_cable = AXGBE_SFP_CABLE_ACTIVE;
 		phy_data->sfp_speed = AXGBE_SFP_SPEED_1000;

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

* [dpdk-dev] [PATCH v2 05/18] drivers/net/nfp/nfpcore: fix strncpy misuse
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (3 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 04/18] drivers/net/axgbe: fix broken eeprom string comp Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  9:49   ` Alejandro Lucero
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 06/18] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use Andy Green
                   ` (12 subsequent siblings)
  17 siblings, 1 reply; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
index 4e6c66624..52b294888 100644
--- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
+++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
@@ -31,6 +31,8 @@
 #include <sys/file.h>
 #include <sys/stat.h>
 
+#include <rte_string_fns.h>
+
 #include "nfp_cpp.h"
 #include "nfp_target.h"
 #include "nfp6000/nfp6000.h"
@@ -846,7 +848,7 @@ nfp6000_init(struct nfp_cpp *cpp, const char *devname)
 
 
 	memset(desc->busdev, 0, BUSDEV_SZ);
-	strncpy(desc->busdev, devname, strlen(devname));
+	strlcpy(desc->busdev, devname, sizeof(desc->busdev));
 
 	ret = nfp_acquire_process_lock(desc);
 	if (ret)

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

* [dpdk-dev] [PATCH v2 06/18] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (4 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 05/18] drivers/net/nfp/nfpcore: fix strncpy misuse Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  9:53   ` Alejandro Lucero
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 07/18] drivers/net/nfp: don't memcpy out of source range Andy Green
                   ` (11 subsequent siblings)
  17 siblings, 1 reply; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/drivers/net/nfp/nfpcore/nfp_resource.c:
76:2:error: ‘strncpy’ output may be truncated copying 8 bytes from
a string of length 8 [-Werror=stringop-truncation]
  strncpy(name_pad, res->name, sizeof(name_pad));

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/nfp/nfpcore/nfp_resource.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c b/drivers/net/nfp/nfpcore/nfp_resource.c
index e1df2b2e1..a165b93df 100644
--- a/drivers/net/nfp/nfpcore/nfp_resource.c
+++ b/drivers/net/nfp/nfpcore/nfp_resource.c
@@ -7,6 +7,8 @@
 #include <time.h>
 #include <endian.h>
 
+#include <rte_string_fns.h>
+
 #include "nfp_cpp.h"
 #include "nfp6000/nfp6000.h"
 #include "nfp_resource.h"
@@ -65,15 +67,15 @@ struct nfp_resource {
 static int
 nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res)
 {
-	char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ] = {};
+	char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ + 2];
 	struct nfp_resource_entry entry;
 	uint32_t cpp_id, key;
 	int ret, i;
 
 	cpp_id = NFP_CPP_ID(NFP_RESOURCE_TBL_TARGET, 3, 0);  /* Atomic read */
 
-	memset(name_pad, 0, NFP_RESOURCE_ENTRY_NAME_SZ);
-	strncpy(name_pad, res->name, sizeof(name_pad));
+	memset(name_pad, 0, sizeof(name_pad));
+	strlcpy(name_pad, res->name, sizeof(name_pad));
 
 	/* Search for a matching entry */
 	if (!memcmp(name_pad, NFP_RESOURCE_TBL_NAME "\0\0\0\0\0\0\0\0", 8)) {

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

* [dpdk-dev] [PATCH v2 07/18] drivers/net/nfp: don't memcpy out of source range
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (5 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 06/18] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  9:54   ` Alejandro Lucero
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 08/18] drivers/net/nfp: fix buffer overflow in fw_name Andy Green
                   ` (10 subsequent siblings)
  17 siblings, 1 reply; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:669:2:
error: ‘memcpy’ forming offset [5, 6] is out of the bounds
[0, 4] of object ‘tmp’ with type ‘uint32_t’ {aka ‘unsigned
int’} [-Werror=array-bounds]  memcpy(&hw->mac_addr[0],
&tmp, sizeof(struct ether_addr));

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/nfp/nfp_net.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 048324ec9..199aac40b 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -666,7 +666,7 @@ nfp_net_vf_read_mac(struct nfp_net_hw *hw)
 	uint32_t tmp;
 
 	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
-	memcpy(&hw->mac_addr[0], &tmp, sizeof(struct ether_addr));
+	memcpy(&hw->mac_addr[0], &tmp, 4);
 
 	tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
 	memcpy(&hw->mac_addr[4], &tmp, 2);

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

* [dpdk-dev] [PATCH v2 08/18] drivers/net/nfp: fix buffer overflow in fw_name
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (6 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 07/18] drivers/net/nfp: don't memcpy out of source range Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09 10:04   ` Alejandro Lucero
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 09/18] drivers/net/qede: fix strncpy constant and NUL Andy Green
                   ` (9 subsequent siblings)
  17 siblings, 1 reply; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c: In
function ‘nfp_pf_pci_probe’:
/home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:3160:
23: error: ‘%s’ directive writing up to 99 bytes into a
region of size 76 [-Werror=format-overflow=]
  sprintf(fw_name, "%s/%s.nffw", DEFAULT_FW_PATH, serial);

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/nfp/nfp_net.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
index 199aac40b..d5f0e54e8 100644
--- a/drivers/net/nfp/nfp_net.c
+++ b/drivers/net/nfp/nfp_net.c
@@ -3144,7 +3144,7 @@ nfp_fw_upload(struct rte_pci_device *dev, struct nfp_nsp *nsp, char *card)
 	struct nfp_cpp *cpp = nsp->cpp;
 	int fw_f;
 	char *fw_buf;
-	char fw_name[100];
+	char fw_name[130];
 	char serial[100];
 	struct stat file_stat;
 	off_t fsize, bytes;

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

* [dpdk-dev] [PATCH v2 09/18] drivers/net/qede: fix strncpy constant and NUL
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (7 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 08/18] drivers/net/nfp: fix buffer overflow in fw_name Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 10/18] drivers/net/qede: fix broken strncpy Andy Green
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/qede/base/ecore_int.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/qede/base/ecore_int.c b/drivers/net/qede/base/ecore_int.c
index f43781ba4..d9e22b5ed 100644
--- a/drivers/net/qede/base/ecore_int.c
+++ b/drivers/net/qede/base/ecore_int.c
@@ -6,6 +6,8 @@
  * See LICENSE.qede_pmd for copyright and licensing details.
  */
 
+#include <rte_string_fns.h>
+
 #include "bcm_osal.h"
 #include "ecore.h"
 #include "ecore_spq.h"
@@ -1104,9 +1106,9 @@ static enum _ecore_status_t ecore_int_deassertion(struct ecore_hwfn *p_hwfn,
 							      p_aeu->bit_name,
 							      num);
 					else
-						OSAL_STRNCPY(bit_name,
-							     p_aeu->bit_name,
-							     30);
+						strlcpy(bit_name,
+							p_aeu->bit_name,
+							sizeof(bit_name));
 
 					/* We now need to pass bitmask in its
 					 * correct position.

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

* [dpdk-dev] [PATCH v2 10/18] drivers/net/qede: fix broken strncpy
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (8 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 09/18] drivers/net/qede: fix strncpy constant and NUL Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 11/18] drivers/net/sfc: fix strncpy length Andy Green
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/drivers/net/qede/qede_main.c: In function
‘qed_slowpath_start’:
/home/agreen/projects/dpdk/drivers/net/qede/qede_main.c:307:3:
error: ‘strncpy’ output may be truncated copying 12 bytes from a
string of length 127 [-Werror=stringop-truncation]
   strncpy((char *)drv_version.name, (const char *)params->name,
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    MCP_DRV_VER_STR_SIZE - 4);
    ~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/qede/qede_main.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/qede/qede_main.c b/drivers/net/qede/qede_main.c
index 2333ca073..fcfc32d0d 100644
--- a/drivers/net/qede/qede_main.c
+++ b/drivers/net/qede/qede_main.c
@@ -9,6 +9,7 @@
 #include <limits.h>
 #include <time.h>
 #include <rte_alarm.h>
+#include <rte_string_fns.h>
 
 #include "qede_ethdev.h"
 
@@ -303,9 +304,9 @@ static int qed_slowpath_start(struct ecore_dev *edev,
 		drv_version.version = (params->drv_major << 24) |
 		    (params->drv_minor << 16) |
 		    (params->drv_rev << 8) | (params->drv_eng);
-		/* TBD: strlcpy() */
-		strncpy((char *)drv_version.name, (const char *)params->name,
-			MCP_DRV_VER_STR_SIZE - 4);
+		strlcpy((char *)drv_version.name, (const char *)params->name,
+			sizeof(drv_version.name));
+		drv_version.name[sizeof(drv_version.name) - 1] = '\0';
 		rc = ecore_mcp_send_drv_version(hwfn, hwfn->p_main_ptt,
 						&drv_version);
 		if (rc) {

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

* [dpdk-dev] [PATCH v2 11/18] drivers/net/sfc: fix strncpy length
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (9 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 10/18] drivers/net/qede: fix broken strncpy Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 12/18] drivers/net/sfc: fix strncpy size and NUL Andy Green
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/sfc/sfc_ethdev.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index e42d55350..ef5e9ecb2 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -13,6 +13,7 @@
 #include <rte_pci.h>
 #include <rte_bus_pci.h>
 #include <rte_errno.h>
+#include <rte_string_fns.h>
 
 #include "efx.h"
 
@@ -741,9 +742,8 @@ sfc_xstats_get_names_by_id(struct rte_eth_dev *dev,
 		if ((ids == NULL) || (ids[nb_written] == nb_supported)) {
 			char *name = xstats_names[nb_written++].name;
 
-			strncpy(name, efx_mac_stat_name(sa->nic, i),
+			strlcpy(name, efx_mac_stat_name(sa->nic, i),
 				sizeof(xstats_names[0].name));
-			name[sizeof(xstats_names[0].name) - 1] = '\0';
 		}
 
 		++nb_supported;

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

* [dpdk-dev] [PATCH v2 12/18] drivers/net/sfc: fix strncpy size and NUL
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (10 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 11/18] drivers/net/sfc: fix strncpy length Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 13/18] drivers/net/vdev: readlink inputs cannot be aliased Andy Green
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/sfc/sfc_ethdev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index ef5e9ecb2..a8c0f8e19 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -664,7 +664,7 @@ sfc_xstats_get_names(struct rte_eth_dev *dev,
 	for (i = 0; i < EFX_MAC_NSTATS; ++i) {
 		if (EFX_MAC_STAT_SUPPORTED(port->mac_stats_mask, i)) {
 			if (xstats_names != NULL && nstats < xstats_count)
-				strncpy(xstats_names[nstats].name,
+				strlcpy(xstats_names[nstats].name,
 					efx_mac_stat_name(sa->nic, i),
 					sizeof(xstats_names[0].name));
 			nstats++;

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

* [dpdk-dev] [PATCH v2 13/18] drivers/net/vdev: readlink inputs cannot be aliased
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (11 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 12/18] drivers/net/sfc: fix strncpy size and NUL Andy Green
@ 2018-05-09  1:31 ` Andy Green
  2018-05-09 15:33   ` Stephen Hemminger
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 14/18] drivers/net/vdev: fix 3 x strncpy misuse Andy Green
                   ` (4 subsequent siblings)
  17 siblings, 1 reply; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:31 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/drivers/net/vdev_netvsc/
vdev_netvsc.c:335:2:error: passing argument 2 to restrict-
qualified parameter aliases with argument 1 [-Werror=restrict]
  ret = readlink(buf, buf, size);
  ^~~

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/vdev_netvsc/vdev_netvsc.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index c321a9f1b..e0d3c1c7c 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -327,12 +327,14 @@ static int
 vdev_netvsc_sysfs_readlink(char *buf, size_t size, const char *if_name,
 			   const char *relpath)
 {
+	char in[160];
 	int ret;
 
-	ret = snprintf(buf, size, "/sys/class/net/%s/%s", if_name, relpath);
-	if (ret == -1 || (size_t)ret >= size)
+	ret = snprintf(in, sizeof(buf) - 1, "/sys/class/net/%s/%s",
+		       if_name, relpath);
+	if (ret == -1 || (size_t)ret >= sizeof(buf) - 1)
 		return -ENOBUFS;
-	ret = readlink(buf, buf, size);
+	ret = readlink(in, buf, size);
 	if (ret == -1)
 		return -errno;
 	if ((size_t)ret >= size - 1)

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

* [dpdk-dev] [PATCH v2 14/18] drivers/net/vdev: fix 3 x strncpy misuse
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (12 preceding siblings ...)
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 13/18] drivers/net/vdev: readlink inputs cannot be aliased Andy Green
@ 2018-05-09  1:32 ` Andy Green
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 15/18] app/test-pmd: can't find include Andy Green
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:32 UTC (permalink / raw)
  To: dev

Signed-off-by: Andy Green <andy@warmcat.com>
---
 drivers/net/vdev_netvsc/vdev_netvsc.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
index e0d3c1c7c..41662304b 100644
--- a/drivers/net/vdev_netvsc/vdev_netvsc.c
+++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
@@ -35,6 +35,7 @@
 #include <rte_hypervisor.h>
 #include <rte_kvargs.h>
 #include <rte_log.h>
+#include <rte_string_fns.h>
 
 #define VDEV_NETVSC_DRIVER net_vdev_netvsc
 #define VDEV_NETVSC_DRIVER_NAME RTE_STR(VDEV_NETVSC_DRIVER)
@@ -182,7 +183,7 @@ vdev_netvsc_foreach_iface(int (*func)(const struct if_nameindex *iface,
 		is_netvsc_ret = vdev_netvsc_iface_is_netvsc(&iface[i]) ? 1 : 0;
 		if (is_netvsc ^ is_netvsc_ret)
 			continue;
-		strncpy(req.ifr_name, iface[i].if_name, sizeof(req.ifr_name));
+		strlcpy(req.ifr_name, iface[i].if_name, sizeof(req.ifr_name));
 		if (ioctl(s, SIOCGIFHWADDR, &req) == -1) {
 			DRV_LOG(WARNING, "cannot retrieve information about"
 					 " interface \"%s\": %s",
@@ -384,7 +385,7 @@ vdev_netvsc_device_probe(const struct if_nameindex *iface,
 		DRV_LOG(DEBUG,
 			"NetVSC interface \"%s\" (index %u) renamed \"%s\"",
 			ctx->if_name, ctx->if_index, iface->if_name);
-		strncpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name));
+		strlcpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name));
 		return 0;
 	}
 	if (!is_same_ether_addr(eth_addr, &ctx->if_addr))
@@ -582,7 +583,7 @@ vdev_netvsc_netvsc_probe(const struct if_nameindex *iface,
 		goto error;
 	}
 	ctx->id = vdev_netvsc_ctx_count;
-	strncpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name));
+	strlcpy(ctx->if_name, iface->if_name, sizeof(ctx->if_name));
 	ctx->if_index = iface->if_index;
 	ctx->if_addr = *eth_addr;
 	ctx->pipe[0] = -1;

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

* [dpdk-dev] [PATCH v2 15/18] app/test-pmd: can't find include
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (13 preceding siblings ...)
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 14/18] drivers/net/vdev: fix 3 x strncpy misuse Andy Green
@ 2018-05-09  1:32 ` Andy Green
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 16/18] app/proc-info: fix sprintf overrun bug Andy Green
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:32 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/app/test-pmd/cmdline.c:64:10:
fatal error: rte_pmd_dpaa.h: No such file or directory
 #include <rte_pmd_dpaa.h>
          ^~~~~~~~~~~~~~~~

Signed-off-by: Andy Green <andy@warmcat.com>
---
 app/test-pmd/Makefile |    1 +
 1 file changed, 1 insertion(+)

diff --git a/app/test-pmd/Makefile b/app/test-pmd/Makefile
index 60ae9b9c1..a0fdd0e11 100644
--- a/app/test-pmd/Makefile
+++ b/app/test-pmd/Makefile
@@ -13,6 +13,7 @@ APP = testpmd
 CFLAGS += -DALLOW_EXPERIMENTAL_API
 CFLAGS += -O3
 CFLAGS += $(WERROR_FLAGS)
+CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa
 
 #
 # all source are stored in SRCS-y

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

* [dpdk-dev] [PATCH v2 16/18] app/proc-info: fix sprintf overrun bug
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (14 preceding siblings ...)
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 15/18] app/test-pmd: can't find include Andy Green
@ 2018-05-09  1:32 ` Andy Green
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 17/18] app/test-bbdev: test-bbdev: strcpy ok for allocated string Andy Green
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 18/18] app/test-bbdev: " Andy Green
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:32 UTC (permalink / raw)
  To: dev

/home/agreen/projects/dpdk/app/proc-info/main.c: In function
‘nic_xstats_display’:
/home/agreen/projects/dpdk/app/proc-info/main.c:495:45:
error: ‘%s’ directive writing up to 255 bytes into a region
of size between 165 and 232 [-Werror=format-overflow=]
    sprintf(buf, "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
                                             ^~
     PRIu64"\n", host_id, port_id, counter_type,
                                   ~~~~~~~~~~~~
/home/agreen/projects/dpdk/app/proc-info/main.c:495:4: note:
‘sprintf’ output between 31 and 435 bytes into a destination
of size 256
    sprintf(buf, "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     PRIu64"\n", host_id, port_id, counter_type,
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     xstats_names[i].name, values[i]);

Signed-off-by: Andy Green <andy@warmcat.com>
---
 app/proc-info/main.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index 539e13243..df46c235e 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -488,14 +488,19 @@ nic_xstats_display(uint16_t port_id)
 		if (enable_collectd_format) {
 			char counter_type[MAX_STRING_LEN];
 			char buf[MAX_STRING_LEN];
+			size_t n;
 
 			collectd_resolve_cnt_type(counter_type,
 						  sizeof(counter_type),
 						  xstats_names[i].name);
-			sprintf(buf, "PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
+			n = snprintf(buf, MAX_STRING_LEN,
+				"PUTVAL %s/dpdkstat-port.%u/%s-%s N:%"
 				PRIu64"\n", host_id, port_id, counter_type,
 				xstats_names[i].name, values[i]);
-			ret = write(stdout_fd, buf, strlen(buf));
+			buf[sizeof(buf) - 1] = '\0';
+			if (n > sizeof(buf) - 1)
+				n = sizeof(buf) - 1;
+			ret = write(stdout_fd, buf, n);
 			if (ret < 0)
 				goto err;
 		} else {

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

* [dpdk-dev] [PATCH v2 17/18] app/test-bbdev: test-bbdev: strcpy ok for allocated string
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (15 preceding siblings ...)
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 16/18] app/proc-info: fix sprintf overrun bug Andy Green
@ 2018-05-09  1:32 ` Andy Green
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 18/18] app/test-bbdev: " Andy Green
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:32 UTC (permalink / raw)
  To: dev

Signed-off-by: Andy Green <andy@warmcat.com>
---
 app/test-bbdev/test_bbdev_vector.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/test-bbdev/test_bbdev_vector.c b/app/test-bbdev/test_bbdev_vector.c
index addef0572..5ad2a6535 100644
--- a/app/test-bbdev/test_bbdev_vector.c
+++ b/app/test-bbdev/test_bbdev_vector.c
@@ -890,7 +890,7 @@ test_bbdev_vector_read(const char *filename,
 		}
 
 		memset(entry, 0, strlen(line) + 1);
-		strncpy(entry, line, strlen(line));
+		strcpy(entry, line);
 
 		/* check if entry ends with , or = */
 		if (entry[strlen(entry) - 1] == ','

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

* [dpdk-dev] [PATCH v2 18/18] app/test-bbdev: strcpy ok for allocated string
  2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
                   ` (16 preceding siblings ...)
  2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 17/18] app/test-bbdev: test-bbdev: strcpy ok for allocated string Andy Green
@ 2018-05-09  1:32 ` Andy Green
  17 siblings, 0 replies; 25+ messages in thread
From: Andy Green @ 2018-05-09  1:32 UTC (permalink / raw)
  To: dev

Signed-off-by: Andy Green <andy@warmcat.com>
---
 app/test-bbdev/test_bbdev_vector.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/test-bbdev/test_bbdev_vector.c b/app/test-bbdev/test_bbdev_vector.c
index 5ad2a6535..373f94984 100644
--- a/app/test-bbdev/test_bbdev_vector.c
+++ b/app/test-bbdev/test_bbdev_vector.c
@@ -912,7 +912,8 @@ test_bbdev_vector_read(const char *filename,
 				}
 
 				entry = entry_extended;
-				strncat(entry, line, strlen(line));
+				/* entry has been allocated accordingly */
+				strcpy(&entry[strlen(entry)], line);
 
 				if (entry[strlen(entry) - 1] != ',')
 					break;

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

* Re: [dpdk-dev] [PATCH v2 03/18] drivers/bus/dpaa: fix inconsistent struct alignment
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 03/18] drivers/bus/dpaa: fix inconsistent struct alignment Andy Green
@ 2018-05-09  8:06   ` Hemant Agrawal
  0 siblings, 0 replies; 25+ messages in thread
From: Hemant Agrawal @ 2018-05-09  8:06 UTC (permalink / raw)
  To: Andy Green, dev


On 5/9/2018 7:01 AM, Andy Green wrote:
> The actual descriptor for qm_mr_entry is 64-byte aligned.
>
> But the original code plays a trick, and puts a u8 common
> to the three descriptor subtypes in the union afterwards
> outside their structure definitions.
>
> Unfortunately since they compose a struct qm_fd with
> alignment 8, this trick destroys the ability of the compiler
> to understand what has happened, resulting in this kind of
> problem:
>
> /home/agreen/projects/dpdk/drivers/bus/dpaa/include/
> fsl_qman.h:354:3: error: alignment 1 of ‘struct <anonymous>’
> is less than 8 [-Werror=packed-not-aligned]
>    } __packed dcern;
>
> on gcc 8 / Fedora 28 out of the box.
>
> This patch moves the u8 verb into the structure definitions
> composed into the union, so the alignment of the parent struct
> containing the alignment 8 object can also be seen to be
> alignment 8 by the compiler.  Uses of .verb are fixed up to use
> .ern.verb (the same offset of +0 inside all the structs in
> the union).
>
> The final struct layout should be unchanged.
>
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
>  drivers/bus/dpaa/base/qbman/qman.c  |   14 +++++++-------
>  drivers/bus/dpaa/include/fsl_qman.h |   24 +++++++++++++-----------
>  2 files changed, 20 insertions(+), 18 deletions(-)

Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
Tested on ubuntu 18.04 with GCC 8.1.0

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

* Re: [dpdk-dev] [PATCH v2 05/18] drivers/net/nfp/nfpcore: fix strncpy misuse
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 05/18] drivers/net/nfp/nfpcore: fix strncpy misuse Andy Green
@ 2018-05-09  9:49   ` Alejandro Lucero
  0 siblings, 0 replies; 25+ messages in thread
From: Alejandro Lucero @ 2018-05-09  9:49 UTC (permalink / raw)
  To: Andy Green; +Cc: dev

On Wed, May 9, 2018 at 2:31 AM, Andy Green <andy@warmcat.com> wrote:

> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
>  drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c |    4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
> b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
> index 4e6c66624..52b294888 100644
> --- a/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
> +++ b/drivers/net/nfp/nfpcore/nfp_cpp_pcie_ops.c
> @@ -31,6 +31,8 @@
>  #include <sys/file.h>
>  #include <sys/stat.h>
>
> +#include <rte_string_fns.h>
> +
>  #include "nfp_cpp.h"
>  #include "nfp_target.h"
>  #include "nfp6000/nfp6000.h"
> @@ -846,7 +848,7 @@ nfp6000_init(struct nfp_cpp *cpp, const char *devname)
>
>
>         memset(desc->busdev, 0, BUSDEV_SZ);
> -       strncpy(desc->busdev, devname, strlen(devname));
> +       strlcpy(desc->busdev, devname, sizeof(desc->busdev));
>
>         ret = nfp_acquire_process_lock(desc);
>         if (ret)
>
>
Acked-by: Alejandro Lucero <alejandro.lucero@netronome.com>
Tested-by: Alejandro Lucero <alejandro.lucero@netronome.com>

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

* Re: [dpdk-dev] [PATCH v2 06/18] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 06/18] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use Andy Green
@ 2018-05-09  9:53   ` Alejandro Lucero
  0 siblings, 0 replies; 25+ messages in thread
From: Alejandro Lucero @ 2018-05-09  9:53 UTC (permalink / raw)
  To: Andy Green; +Cc: dev

On Wed, May 9, 2018 at 2:31 AM, Andy Green <andy@warmcat.com> wrote:

> /home/agreen/projects/dpdk/drivers/net/nfp/nfpcore/nfp_resource.c:
> 76:2:error: ‘strncpy’ output may be truncated copying 8 bytes from
> a string of length 8 [-Werror=stringop-truncation]
>   strncpy(name_pad, res->name, sizeof(name_pad));
>
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
>  drivers/net/nfp/nfpcore/nfp_resource.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/nfp/nfpcore/nfp_resource.c
> b/drivers/net/nfp/nfpcore/nfp_resource.c
> index e1df2b2e1..a165b93df 100644
> --- a/drivers/net/nfp/nfpcore/nfp_resource.c
> +++ b/drivers/net/nfp/nfpcore/nfp_resource.c
> @@ -7,6 +7,8 @@
>  #include <time.h>
>  #include <endian.h>
>
> +#include <rte_string_fns.h>
> +
>  #include "nfp_cpp.h"
>  #include "nfp6000/nfp6000.h"
>  #include "nfp_resource.h"
> @@ -65,15 +67,15 @@ struct nfp_resource {
>  static int
>  nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res)
>  {
> -       char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ] = {};
> +       char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ + 2];
>         struct nfp_resource_entry entry;
>         uint32_t cpp_id, key;
>         int ret, i;
>
>         cpp_id = NFP_CPP_ID(NFP_RESOURCE_TBL_TARGET, 3, 0);  /* Atomic
> read */
>
> -       memset(name_pad, 0, NFP_RESOURCE_ENTRY_NAME_SZ);
> -       strncpy(name_pad, res->name, sizeof(name_pad));
> +       memset(name_pad, 0, sizeof(name_pad));
> +       strlcpy(name_pad, res->name, sizeof(name_pad));
>
>         /* Search for a matching entry */
>         if (!memcmp(name_pad, NFP_RESOURCE_TBL_NAME "\0\0\0\0\0\0\0\0",
> 8)) {
>
>
I'm afraid this patch is breaking the PMD NFP initialization. It is due to
how the name pad is used for getting a key which is compared against a key
generated by the firmware.

Because the name_pad size change, this next change is also required:

-       key = nfp_crc32_posix(name_pad, sizeof(name_pad));

+       key = nfp_crc32_posix(name_pad, NFP_RESOURCE_ENTRY_NAME_SZ);

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

* Re: [dpdk-dev] [PATCH v2 07/18] drivers/net/nfp: don't memcpy out of source range
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 07/18] drivers/net/nfp: don't memcpy out of source range Andy Green
@ 2018-05-09  9:54   ` Alejandro Lucero
  0 siblings, 0 replies; 25+ messages in thread
From: Alejandro Lucero @ 2018-05-09  9:54 UTC (permalink / raw)
  To: Andy Green; +Cc: dev

On Wed, May 9, 2018 at 2:31 AM, Andy Green <andy@warmcat.com> wrote:

> /home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:669:2:
> error: ‘memcpy’ forming offset [5, 6] is out of the bounds
> [0, 4] of object ‘tmp’ with type ‘uint32_t’ {aka ‘unsigned
> int’} [-Werror=array-bounds]  memcpy(&hw->mac_addr[0],
> &tmp, sizeof(struct ether_addr));
>
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
>  drivers/net/nfp/nfp_net.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
> index 048324ec9..199aac40b 100644
> --- a/drivers/net/nfp/nfp_net.c
> +++ b/drivers/net/nfp/nfp_net.c
> @@ -666,7 +666,7 @@ nfp_net_vf_read_mac(struct nfp_net_hw *hw)
>         uint32_t tmp;
>
>         tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR));
> -       memcpy(&hw->mac_addr[0], &tmp, sizeof(struct ether_addr));
> +       memcpy(&hw->mac_addr[0], &tmp, 4);
>
>         tmp = rte_be_to_cpu_32(nn_cfg_readl(hw, NFP_NET_CFG_MACADDR + 4));
>         memcpy(&hw->mac_addr[4], &tmp, 2);
>
>
Acked-by: Alejandro Lucero <alejandro.lucero@netronome.com>
Tested-by: Alejandro Lucero <alejandro.lucero@netronome.com>

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

* Re: [dpdk-dev] [PATCH v2 08/18] drivers/net/nfp: fix buffer overflow in fw_name
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 08/18] drivers/net/nfp: fix buffer overflow in fw_name Andy Green
@ 2018-05-09 10:04   ` Alejandro Lucero
  0 siblings, 0 replies; 25+ messages in thread
From: Alejandro Lucero @ 2018-05-09 10:04 UTC (permalink / raw)
  To: Andy Green; +Cc: dev

On Wed, May 9, 2018 at 2:31 AM, Andy Green <andy@warmcat.com> wrote:

> /home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c: In
> function ‘nfp_pf_pci_probe’:
> /home/agreen/projects/dpdk/drivers/net/nfp/nfp_net.c:3160:
> 23: error: ‘%s’ directive writing up to 99 bytes into a
> region of size 76 [-Werror=format-overflow=]
>   sprintf(fw_name, "%s/%s.nffw", DEFAULT_FW_PATH, serial);
>
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
>  drivers/net/nfp/nfp_net.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/nfp/nfp_net.c b/drivers/net/nfp/nfp_net.c
> index 199aac40b..d5f0e54e8 100644
> --- a/drivers/net/nfp/nfp_net.c
> +++ b/drivers/net/nfp/nfp_net.c
> @@ -3144,7 +3144,7 @@ nfp_fw_upload(struct rte_pci_device *dev, struct
> nfp_nsp *nsp, char *card)
>         struct nfp_cpp *cpp = nsp->cpp;
>         int fw_f;
>         char *fw_buf;
> -       char fw_name[100];
> +       char fw_name[130];
>         char serial[100];
>         struct stat file_stat;
>         off_t fsize, bytes;
>
>
I would prefer to modify the serial char array size instead, and
considering the serial name is fixed, it can be set to 40 safely.

Thanks!

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

* Re: [dpdk-dev] [PATCH v2 13/18] drivers/net/vdev: readlink inputs cannot be aliased
  2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 13/18] drivers/net/vdev: readlink inputs cannot be aliased Andy Green
@ 2018-05-09 15:33   ` Stephen Hemminger
  0 siblings, 0 replies; 25+ messages in thread
From: Stephen Hemminger @ 2018-05-09 15:33 UTC (permalink / raw)
  To: Andy Green; +Cc: dev

On Wed, 09 May 2018 09:31:56 +0800
Andy Green <andy@warmcat.com> wrote:

> /home/agreen/projects/dpdk/drivers/net/vdev_netvsc/
> vdev_netvsc.c:335:2:error: passing argument 2 to restrict-
> qualified parameter aliases with argument 1 [-Werror=restrict]
>   ret = readlink(buf, buf, size);
>   ^~~
> 
> Signed-off-by: Andy Green <andy@warmcat.com>
> ---
>  drivers/net/vdev_netvsc/vdev_netvsc.c |    8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c
> index c321a9f1b..e0d3c1c7c 100644
> --- a/drivers/net/vdev_netvsc/vdev_netvsc.c
> +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c
> @@ -327,12 +327,14 @@ static int
>  vdev_netvsc_sysfs_readlink(char *buf, size_t size, const char *if_name,
>  			   const char *relpath)
>  {
> +	char in[160];
>  	int ret;
>  
> -	ret = snprintf(buf, size, "/sys/class/net/%s/%s", if_name, relpath);
> -	if (ret == -1 || (size_t)ret >= size)
> +	ret = snprintf(in, sizeof(buf) - 1, "/sys/class/net/%s/%s",
> +		       if_name, relpath);

This is wrong.  buf is char * and sizeof(char *) - 1 is 3

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

end of thread, other threads:[~2018-05-09 15:33 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09  1:30 [dpdk-dev] [PATCH v2 00/18] Fix build on gcc8 and various bugs Andy Green
2018-05-09  1:30 ` [dpdk-dev] [PATCH v2 01/18] lib/libtre_table: workaround hash function cast error Andy Green
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 02/18] drivers/bus/pci: fix strncpy dangerous code Andy Green
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 03/18] drivers/bus/dpaa: fix inconsistent struct alignment Andy Green
2018-05-09  8:06   ` Hemant Agrawal
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 04/18] drivers/net/axgbe: fix broken eeprom string comp Andy Green
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 05/18] drivers/net/nfp/nfpcore: fix strncpy misuse Andy Green
2018-05-09  9:49   ` Alejandro Lucero
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 06/18] drivers/net/nfp/nfpcore: fix off-by-one and no NUL on strncpy use Andy Green
2018-05-09  9:53   ` Alejandro Lucero
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 07/18] drivers/net/nfp: don't memcpy out of source range Andy Green
2018-05-09  9:54   ` Alejandro Lucero
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 08/18] drivers/net/nfp: fix buffer overflow in fw_name Andy Green
2018-05-09 10:04   ` Alejandro Lucero
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 09/18] drivers/net/qede: fix strncpy constant and NUL Andy Green
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 10/18] drivers/net/qede: fix broken strncpy Andy Green
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 11/18] drivers/net/sfc: fix strncpy length Andy Green
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 12/18] drivers/net/sfc: fix strncpy size and NUL Andy Green
2018-05-09  1:31 ` [dpdk-dev] [PATCH v2 13/18] drivers/net/vdev: readlink inputs cannot be aliased Andy Green
2018-05-09 15:33   ` Stephen Hemminger
2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 14/18] drivers/net/vdev: fix 3 x strncpy misuse Andy Green
2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 15/18] app/test-pmd: can't find include Andy Green
2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 16/18] app/proc-info: fix sprintf overrun bug Andy Green
2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 17/18] app/test-bbdev: test-bbdev: strcpy ok for allocated string Andy Green
2018-05-09  1:32 ` [dpdk-dev] [PATCH v2 18/18] app/test-bbdev: " Andy Green

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