DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check
@ 2020-09-08 10:06 Ferruh Yigit
  2020-09-08 12:06 ` Raslan Darawsheh
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Ferruh Yigit @ 2020-09-08 10:06 UTC (permalink / raw)
  To: dev, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang, Long Li
  Cc: Ferruh Yigit, Raslan Darawsheh

'__builtin_add_overflow' added to gcc in version 5, earlier versions
causing build error, like gcc 4.8.5 in RHEL7.

Replaced compiler builtin check with arithmetic check.

Fixes: cabb3c0f29f1 ("net/netvsc: check for overflow on packet info from host")

Reported-by: Raslan Darawsheh <rasland@mellanox.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/netvsc/hn_rxtx.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index d8d3f07f56..3e8d3b407d 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -666,7 +666,7 @@ static void hn_rndis_rx_data(struct hn_rx_queue *rxq,
 			     struct hn_rx_bufinfo *rxb,
 			     void *data, uint32_t dlen)
 {
-	unsigned int data_off, data_len, total_len;
+	unsigned int data_off, data_len;
 	unsigned int pktinfo_off, pktinfo_len;
 	const struct rndis_packet_msg *pkt = data;
 	struct hn_rxinfo info = {
@@ -712,8 +712,8 @@ static void hn_rndis_rx_data(struct hn_rx_queue *rxq,
 			goto error;
 	}
 
-	if (__builtin_add_overflow(data_off, data_len, &total_len) ||
-	    total_len > pkt->len)
+	/* overflow check */
+	if (data_len > data_len + data_off || data_len + data_off > pkt->len)
 		goto error;
 
 	if (unlikely(data_len < RTE_ETHER_HDR_LEN))
-- 
2.25.4


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

* Re: [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check
  2020-09-08 10:06 [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check Ferruh Yigit
@ 2020-09-08 12:06 ` Raslan Darawsheh
  2020-09-08 15:47 ` Stephen Hemminger
  2020-09-09 22:05 ` Ajit Khaparde
  2 siblings, 0 replies; 5+ messages in thread
From: Raslan Darawsheh @ 2020-09-08 12:06 UTC (permalink / raw)
  To: Ferruh Yigit, dev, Stephen Hemminger, NBU-Contact-kys,
	NBU-Contact-haiyangz, NBU-Contact-longli
  Cc: Raslan Darawsheh

Hi,

> -----Original Message-----
> From: Ferruh Yigit <ferruh.yigit@intel.com>
> Sent: Tuesday, September 8, 2020 1:07 PM
> To: dev@dpdk.org; Stephen Hemminger <sthemmin@microsoft.com>; NBU-
> Contact-kys <kys@microsoft.com>; NBU-Contact-haiyangz
> <haiyangz@microsoft.com>; NBU-Contact-longli <longli@microsoft.com>
> Cc: Ferruh Yigit <ferruh.yigit@intel.com>; Raslan Darawsheh
> <rasland@mellanox.com>
> Subject: [PATCH] net/netvsc: replace compiler builtin overflow check
> 
> '__builtin_add_overflow' added to gcc in version 5, earlier versions
> causing build error, like gcc 4.8.5 in RHEL7.
> 
> Replaced compiler builtin check with arithmetic check.
> 
> Fixes: cabb3c0f29f1 ("net/netvsc: check for overflow on packet info from
> host")
> 
> Reported-by: Raslan Darawsheh <rasland@mellanox.com>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>

Tested-by: Raslan Darawsheh <rasland@nvidia.com>

> ---
>  drivers/net/netvsc/hn_rxtx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
> index d8d3f07f56..3e8d3b407d 100644
> --- a/drivers/net/netvsc/hn_rxtx.c
> +++ b/drivers/net/netvsc/hn_rxtx.c
> @@ -666,7 +666,7 @@ static void hn_rndis_rx_data(struct hn_rx_queue
> *rxq,
>  			     struct hn_rx_bufinfo *rxb,
>  			     void *data, uint32_t dlen)
>  {
> -	unsigned int data_off, data_len, total_len;
> +	unsigned int data_off, data_len;
>  	unsigned int pktinfo_off, pktinfo_len;
>  	const struct rndis_packet_msg *pkt = data;
>  	struct hn_rxinfo info = {
> @@ -712,8 +712,8 @@ static void hn_rndis_rx_data(struct hn_rx_queue
> *rxq,
>  			goto error;
>  	}
> 
> -	if (__builtin_add_overflow(data_off, data_len, &total_len) ||
> -	    total_len > pkt->len)
> +	/* overflow check */
> +	if (data_len > data_len + data_off || data_len + data_off > pkt->len)
>  		goto error;
> 
>  	if (unlikely(data_len < RTE_ETHER_HDR_LEN))
> --
> 2.25.4

Kindest regards
Raslan Darawsheh

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

* Re: [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check
  2020-09-08 10:06 [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check Ferruh Yigit
  2020-09-08 12:06 ` Raslan Darawsheh
@ 2020-09-08 15:47 ` Stephen Hemminger
  2020-09-10 17:16   ` Ferruh Yigit
  2020-09-09 22:05 ` Ajit Khaparde
  2 siblings, 1 reply; 5+ messages in thread
From: Stephen Hemminger @ 2020-09-08 15:47 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: dev, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang, Long Li,
	Raslan Darawsheh

On Tue,  8 Sep 2020 11:06:42 +0100
Ferruh Yigit <ferruh.yigit@intel.com> wrote:

> '__builtin_add_overflow' added to gcc in version 5, earlier versions
> causing build error, like gcc 4.8.5 in RHEL7.

Sigh. Ok, but the security folks really like __builtin_add_overflow.

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

* Re: [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check
  2020-09-08 10:06 [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check Ferruh Yigit
  2020-09-08 12:06 ` Raslan Darawsheh
  2020-09-08 15:47 ` Stephen Hemminger
@ 2020-09-09 22:05 ` Ajit Khaparde
  2 siblings, 0 replies; 5+ messages in thread
From: Ajit Khaparde @ 2020-09-09 22:05 UTC (permalink / raw)
  To: Ferruh Yigit
  Cc: dpdk-dev, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang,
	Long Li, Raslan Darawsheh

On Tue, Sep 8, 2020 at 3:07 AM Ferruh Yigit <ferruh.yigit@intel.com> wrote:

> '__builtin_add_overflow' added to gcc in version 5, earlier versions
> causing build error, like gcc 4.8.5 in RHEL7.
>
> Replaced compiler builtin check with arithmetic check.
>
> Fixes: cabb3c0f29f1 ("net/netvsc: check for overflow on packet info from
> host")
>
> Reported-by: Raslan Darawsheh <rasland@mellanox.com>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>
Tested-by: Ajit Khaparde <ajit.khaparde@broadcom.com>


> ---
>  drivers/net/netvsc/hn_rxtx.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
> index d8d3f07f56..3e8d3b407d 100644
> --- a/drivers/net/netvsc/hn_rxtx.c
> +++ b/drivers/net/netvsc/hn_rxtx.c
> @@ -666,7 +666,7 @@ static void hn_rndis_rx_data(struct hn_rx_queue *rxq,
>                              struct hn_rx_bufinfo *rxb,
>                              void *data, uint32_t dlen)
>  {
> -       unsigned int data_off, data_len, total_len;
> +       unsigned int data_off, data_len;
>         unsigned int pktinfo_off, pktinfo_len;
>         const struct rndis_packet_msg *pkt = data;
>         struct hn_rxinfo info = {
> @@ -712,8 +712,8 @@ static void hn_rndis_rx_data(struct hn_rx_queue *rxq,
>                         goto error;
>         }
>
> -       if (__builtin_add_overflow(data_off, data_len, &total_len) ||
> -           total_len > pkt->len)
> +       /* overflow check */
> +       if (data_len > data_len + data_off || data_len + data_off >
> pkt->len)
>                 goto error;
>
>         if (unlikely(data_len < RTE_ETHER_HDR_LEN))
> --
> 2.25.4
>
>

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

* Re: [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check
  2020-09-08 15:47 ` Stephen Hemminger
@ 2020-09-10 17:16   ` Ferruh Yigit
  0 siblings, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2020-09-10 17:16 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: dev, Stephen Hemminger, K. Y. Srinivasan, Haiyang Zhang, Long Li,
	Raslan Darawsheh

On 9/8/2020 4:47 PM, Stephen Hemminger wrote:
> On Tue,  8 Sep 2020 11:06:42 +0100
> Ferruh Yigit <ferruh.yigit@intel.com> wrote:
> 
>> '__builtin_add_overflow' added to gcc in version 5, earlier versions
>> causing build error, like gcc 4.8.5 in RHEL7.
> 
> Sigh. Ok, but the security folks really like __builtin_add_overflow.
> 

Converting to an explicit ack:
Acked-by: Stephen Hemminger <stephen@networkplumber.org>

Applied to dpdk-next-net/main, thanks.

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

end of thread, other threads:[~2020-09-10 17:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 10:06 [dpdk-dev] [PATCH] net/netvsc: replace compiler builtin overflow check Ferruh Yigit
2020-09-08 12:06 ` Raslan Darawsheh
2020-09-08 15:47 ` Stephen Hemminger
2020-09-10 17:16   ` Ferruh Yigit
2020-09-09 22:05 ` Ajit Khaparde

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