kni: fix build with gcc 8.1
PATCH 1/1 kni: fix build with gcc 8.1
Error observed when CONFIG_RTE_KNI_KMOD_ETHTOOL config option is enabled.
build error:
In function ‘strncpy’,
inlined from ‘igb_get_drvinfo’ at
.../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2:
.../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output
may be truncated copying 31 bytes from a string of length 42
[-Werror=stringop-truncation]
return __builtin_strncpy(p, q, size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by reducing the adapter->fw_version size and adjusting strncpy limit size.
--- kernel/linux/kni/ethtool/igb/igb.h | 2 +- kernel/linux/kni/ethtool/igb/igb_ethtool.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
kernel/linux/kni/ethtool/igb/igb.h +1 -1
@@ -592,7 +592,7 @@ struct igb_adapter {int int_mode;u32 rss_queues;u32 vmdq_pools; -char fw_version[43 ]; +char fw_version[32 ];u32 wvbr;struct igb_mac_addr *mac_table;#ifdef CONFIG_IGB_VMDQ_NETDEV
kernel/linux/kni/ethtool/igb/igb_ethtool.c +1 -1
@@ -812,7 +812,7 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 );strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); +sizeof (drvinfo->fw_version));strncpy (drvinfo->bus_info,pci_name (adapter->pdev),sizeof (drvinfo->bus_info) -1 ); drvinfo->n_stats =IGB_STATS_LEN ; drvinfo->testinfo_len =IGB_TEST_LEN ;
Signature · 1 line
2.17.1
Quoted 29 lines · On Tue, 19 Jun 2018 13:08:55 +0100 Ferruh Yigit <[email protected]> wrote:
Error observed when
CONFIG_RTE_KNI_KMOD_ETHTOOLconfig option is enabled.build error:
In function ‘strncpy’,inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by reducing the
adapter->fw_versionsize and adjusting strncpy limit size.Signed-off-by Ferruh Yigit <[email protected]>--- kernel/linux/kni/ethtool/igb/igb.h | 2 +- kernel/linux/kni/ethtool/igb/igb_ethtool.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)kernel/linux/kni/ethtool/igb/igb.h +0
-0
kernel/linux/kni/ethtool/igb/igb.h struct igb_adapter { · line 595
Quoted 5 lines
kernel/linux/kni/ethtool/igb/igb.h +1
-1@@ -592,7 +592,7 @@ struct igb_adapter {int int_mode;u32 rss_queues;u32 vmdq_pools; -char fw_version[43 ]; +char fw_version[32 ];
Use ETHTOOL_FWVERS_LEN?
kernel/linux/kni/ethtool/igb/igb_ethtool.c static void igb_get_drvinfo(struct net_device *netdev, · line 815
Quoted 13 lines
kernel/linux/kni/ethtool/igb/igb.h +0
-0u32 wvbr;struct igb_mac_addr *mac_table;#ifdef CONFIG_IGB_VMDQ_NETDEV kernel/linux/kni/ethtool/igb/igb_ethtool.c +1
-1@@ -812,7 +812,7 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 );strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); +sizeof (drvinfo->fw_version));
Why not:
strlcpy(drvinfo->fw_version, adapter->fw_version, sizeof(drvinfo->fw_version));
Quoted 27 lines · Stephen Hemminger
Quoted 24 lines · On Tue, 19 Jun 2018 13:08:55 +0100 Ferruh Yigit <[email protected]> wrote:
Error observed when
CONFIG_RTE_KNI_KMOD_ETHTOOLconfig option is enabled.build error:
In function ‘strncpy’,inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by reducing the
adapter->fw_versionsize and adjusting strncpy limit size.Signed-off-by Ferruh Yigit <[email protected]>--- kernel/linux/kni/ethtool/igb/igb.h | 2 +- kernel/linux/kni/ethtool/igb/igb_ethtool.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 12 lines
kernel/linux/kni/ethtool/igb/igb.h struct igb_adapter { · line 595
Quoted 10 lines
kernel/linux/kni/ethtool/igb/igb.h +1
-1@@ -592,7 +592,7 @@ struct igb_adapter {int int_mode;u32 rss_queues;u32 vmdq_pools; -char fw_version[43 ]; +char fw_version[32 ];Use
ETHTOOL_FWVERS_LEN?
Yes, that is what drvinfo->fw_version uses, and it seems it has been around enough to not cause any build issue, will use that one.
Quoted 11 lines
Quoted 11 lines
kernel/linux/kni/ethtool/igb/igb.h +0
-0u32 wvbr;struct igb_mac_addr *mac_table;#ifdef CONFIG_IGB_VMDQ_NETDEV kernel/linux/kni/ethtool/igb/igb_ethtool.c +0
-0@@ -812,7 +812,7 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 );
Quoted 7 lines
kernel/linux/kni/ethtool/igb/igb_ethtool.c static void igb_get_drvinfo(struct net_device *netdev, · line 815
Quoted 3 lines
kernel/linux/kni/ethtool/igb/igb_ethtool.c +1
-1strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); +sizeof (drvinfo->fw_version));Why not:
strlcpy(drvinfo->fw_version, adapter->fw_version, sizeof(drvinfo->fw_version));
Just to be cautious about changing API, to not have any problem with older version of kernels.
But it seems strlcpy supported long enough to not cause an issue, I will use it.
Quoted 41 lines · Ferruh Yigit
Quoted 27 lines · Stephen Hemminger
Quoted 24 lines · On Tue, 19 Jun 2018 13:08:55 +0100 Ferruh Yigit <[email protected]> wrote:
Error observed when
CONFIG_RTE_KNI_KMOD_ETHTOOLconfig option is enabled.build error:
In function ‘strncpy’,inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by reducing the
adapter->fw_versionsize and adjusting strncpy limit size.Signed-off-by Ferruh Yigit <[email protected]>--- kernel/linux/kni/ethtool/igb/igb.h | 2 +- kernel/linux/kni/ethtool/igb/igb_ethtool.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Quoted 12 lines
kernel/linux/kni/ethtool/igb/igb.h struct igb_adapter { · line 595
Quoted 10 lines
kernel/linux/kni/ethtool/igb/igb.h +1
-1@@ -592,7 +592,7 @@ struct igb_adapter {int int_mode;u32 rss_queues;u32 vmdq_pools; -char fw_version[43 ]; +char fw_version[32 ];Use
ETHTOOL_FWVERS_LEN?
Quoted 2 lines
Yes, that is what
drvinfo->fw_versionuses, and it seems it has been around enough to not cause any build issue, will use that one.
Ah so much fun, it has been updated to 43 by me in the past, to prevent another warning [1] which another part of code has potential to write larger string to fw_version.
Reducing value back to 32 may bring back that old warning ...
Quoted 24 lines
Quoted 12 lines
Quoted 12 lines
kernel/linux/kni/ethtool/igb/igb.h +0
-0u32 wvbr;struct igb_mac_addr *mac_table;#ifdef CONFIG_IGB_VMDQ_NETDEV kernel/linux/kni/ethtool/igb/igb_ethtool.c +0
-0@@ -812,7 +812,7 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 );Quoted 7 lines
kernel/linux/kni/ethtool/igb/igb_ethtool.c static void igb_get_drvinfo(struct net_device *netdev, · line 815
Quoted 3 lines
kernel/linux/kni/ethtool/igb/igb_ethtool.c +1
-1strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); +sizeof (drvinfo->fw_version));Why not:
strlcpy(drvinfo->fw_version, adapter->fw_version, sizeof(drvinfo->fw_version));Just to be cautious about changing API, to not have any problem with older version of kernels.
But it seems strlcpy supported long enough to not cause an issue, I will use it.
Quoted 22 lines
-----Original Message-----
From: stable [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Tuesday, June 19, 2018 1:09 PM
To: Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]
Subject: [dpdk-stable] [PATCH] kni: fix build with gcc 8.1Error observed when
CONFIG_RTE_KNI_KMOD_ETHTOOLconfig option is enabled.build error:
In function ‘strncpy’,inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 4 lines
Fixed by reducing the
adapter->fw_versionsize and adjusting strncpy limit size.
Fixes line?
Quoted 1 line
Signed-off-by Ferruh Yigit <[email protected]>
...
kernel/linux/kni/ethtool/igb/igb_ethtool.c static void igb_get_drvinfo(struct net_device *netdev, · line 818
Quoted 11 lines
kernel/linux/kni/ethtool/igb/igb_ethtool.c +1
-1@@ -812,7 +812,7 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 );strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); +sizeof (drvinfo->fw_version));strncpy (drvinfo->bus_info,pci_name (adapter->pdev),sizeof (drvinfo- >bus_info) -1);
This patch fixes the compilation issue, but should we use strlcpy instead of strncpy?
Thanks,
Pablo
Quoted 22 lines · Pablo
Quoted 22 lines
-----Original Message-----
From: stable [mailto:[email protected]] On Behalf Of Ferruh Yigit
Sent: Tuesday, June 19, 2018 1:09 PM
To: Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]
Subject: [dpdk-stable] [PATCH] kni: fix build with gcc 8.1Error observed when
CONFIG_RTE_KNI_KMOD_ETHTOOLconfig option is enabled.build error:
In function ‘strncpy’,inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 6 lines
Quoted 4 lines
Fixed by reducing the
adapter->fw_versionsize and adjusting strncpy limit size.Fixes line?
I will add.
Quoted 22 lines
Quoted 2 lines
Signed-off-by Ferruh Yigit <[email protected]>...
kernel/linux/kni/ethtool/igb/igb_ethtool.c static void igb_get_drvinfo(struct net_device *netdev, · line 818
Quoted 11 lines
kernel/linux/kni/ethtool/igb/igb_ethtool.c +1
-1@@ -812,7 +812,7 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 );strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); +sizeof (drvinfo->fw_version));strncpy (drvinfo->bus_info,pci_name (adapter->pdev),sizeof (drvinfo- > bus_info) -1);This patch fixes the compilation issue, but should we use strlcpy instead of strncpy?
Thanks,
Pablo
PATCH v2 1/1 kni: fix build with gcc 8.1
In reply to Ferruh YigitError observed when CONFIG_RTE_KNI_KMOD_ETHTOOL config option is enabled.
build error:
In function ‘strncpy’,
inlined from ‘igb_get_drvinfo’ at
.../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2:
.../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output
may be truncated copying 31 bytes from a string of length 42
[-Werror=stringop-truncation]
return __builtin_strncpy(p, q, size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by using strlcpy instead of strncpy.
adapter->fw_version size kept same because ofc3698192940c ("kni: fix build with gcc 7.1")
Also next line strncpy usage replaced with strlcpy while arround.
---
v2:
* used strlcpy instead of strncpy
* Updated strncpy usage in next line to strlcpy too
* Added fixes line
--- kernel/linux/kni/ethtool/igb/igb_ethtool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
(quoted diff) +0 -0
b/kernel/linux/kni/ethtool/igb/igb_ethtool.c
index 064528bcf..002f75c48 100644
kernel/linux/kni/ethtool/igb/igb_ethtool.c +4 -2
@@ -811,9 +811,10 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->driver, igb_driver_name,sizeof (drvinfo->driver) -1 );strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 ); -strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); -strncpy (drvinfo->bus_info,pci_name (adapter->pdev),sizeof (drvinfo->bus_info) -1 ); +strlcpy (drvinfo->fw_version, adapter->fw_version, + sizeof(drvinfo->fw_version)); +strlcpy (drvinfo->bus_info,pci_name (adapter->pdev), +sizeof (drvinfo->bus_info)); drvinfo->n_stats =IGB_STATS_LEN ; drvinfo->testinfo_len =IGB_TEST_LEN ; drvinfo->regdump_len =igb_get_regs_len (netdev);
Signature · 1 line
2.17.1
26/06/2018 11:02, Ferruh Yigit:
kernel/linux/kni/ethtool/igb/igb_ethtool.c static void igb_get_drvinfo(struct net_device *netdev, · line 814
Quoted 7 lines
kernel/linux/kni/ethtool/igb/igb_ethtool.c +0
-1@@ -811,9 +811,10 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->driver, igb_driver_name,sizeof (drvinfo->driver) -1 );strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 ); - strncpy(drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 );
There is a leading space before the minus of first line.
PATCH v3 1/1 kni: fix build with gcc 8.1
In reply to Ferruh YigitError observed when CONFIG_RTE_KNI_KMOD_ETHTOOL config option is enabled.
build error:
In function ‘strncpy’,
inlined from ‘igb_get_drvinfo’ at
.../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2:
.../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output
may be truncated copying 31 bytes from a string of length 42
[-Werror=stringop-truncation]
return __builtin_strncpy(p, q, size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by using strlcpy instead of strncpy.
adapter->fw_version size kept same because ofc3698192940c ("kni: fix build with gcc 7.1")
Also next line strncpy usage replaced with strlcpy while arround.
---
v2:
* used strlcpy instead of strncpy
* Updated strncpy usage in next line to strlcpy too
* Added fixes line
v3:
* fix patch syntax corrupted during send
--- kernel/linux/kni/ethtool/igb/igb_ethtool.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/linux/kni/ethtool/igb/igb_ethtool.c +4 -3
@@ -811,9 +811,10 @@ static void igb_get_drvinfo(struct net_device *netdev,strncpy (drvinfo->driver, igb_driver_name,sizeof (drvinfo->driver) -1 );strncpy (drvinfo->version, igb_driver_version,sizeof (drvinfo->version) -1 ); -strncpy (drvinfo->fw_version, adapter->fw_version, -sizeof (drvinfo->fw_version) -1 ); -strncpy (drvinfo->bus_info,pci_name (adapter->pdev),sizeof (drvinfo->bus_info) -1 ); +strlcpy (drvinfo->fw_version, adapter->fw_version, +sizeof (drvinfo->fw_version)); +strlcpy (drvinfo->bus_info,pci_name (adapter->pdev), +sizeof (drvinfo->bus_info)); drvinfo->n_stats =IGB_STATS_LEN ; drvinfo->testinfo_len =IGB_TEST_LEN ; drvinfo->regdump_len =igb_get_regs_len (netdev);
Signature · 1 line
2.17.1
Quoted 28 lines
-----Original Message-----
From: Yigit, Ferruh
Sent: Tuesday, June 26, 2018 12:38 PM
To: Yigit, Ferruh <[email protected]>
Cc: [email protected]; [email protected]; De Lara Guarch, Pablo <[email protected]>; [email protected]
Subject: [PATCH v3] kni: fix build with gcc 8.1Error observed when
CONFIG_RTE_KNI_KMOD_ETHTOOLconfig option is enabled.build error:
In function ‘strncpy’,inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by using strlcpy instead of strncpy.
adapter->fw_versionsize kept same because ofc3698192940c("kni: fix build with gcc 7.1")
Quoted 6 lines
Also next line strncpy usage replaced with strlcpy while arround.
Fixes c3698192940c ("kni: fix build with gcc 7.1")Signed-off-by Ferruh Yigit <[email protected]>
Thomas Monjalon
Applied26/06/2018 15:43, De Lara Guarch, Pablo:
Quoted 19 lines
Quoted 19 lines
Error observed when
CONFIG_RTE_KNI_KMOD_ETHTOOLconfig option is enabled.build error:
In function ‘strncpy’,inlined from ‘igb_get_drvinfo’ at .../dpdk/build/build/kernel/linux/kni/igb_ethtool.c:814:2: .../include/linux/string.h:246:9: error: ‘__builtin_strncpy’ output may be truncated copying 31 bytes from a string of length 42 [-Werror=stringop-truncation] return __builtin_strncpy(p, q, size); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~Fixed by using strlcpy instead of strncpy.
adapter->fw_versionsize kept same because ofc3698192940c("kni: fix build with gcc 7.1")
Quoted 8 lines
Quoted 6 lines
Also next line strncpy usage replaced with strlcpy while arround.
Fixes c3698192940c ("kni: fix build with gcc 7.1")Signed-off-by Ferruh Yigit <[email protected]>Acked-by Pablo de Lara <[email protected]>
Applied, thanks