net/netvsc: replace compiler builtin overflow check
PATCH 1/1 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.
--- drivers/net/netvsc/hn_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/netvsc/hn_rxtx.c +3 -3
@@ -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 ))
Signature · 1 line
2.25.4
Hi,
Quoted 13 lines
-----Original Message-----
From: Ferruh Yigit <[email protected]>
Sent: Tuesday, September 8, 2020 1:07 PM
To: [email protected]; Stephen Hemminger <[email protected]>; NBU- Contact-kys <[email protected]>; NBU-Contact-haiyangz <[email protected]>; NBU-Contact-longli <[email protected]>
Cc: Ferruh Yigit <[email protected]>; Raslan Darawsheh <[email protected]>
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.
Quoted 7 lines
Replaced compiler builtin check with arithmetic check.
Fixes cabb3c0f29f1 ("net/netvsc: check for overflow on packet info fromhost")
Reported-by Raslan Darawsheh <[email protected]>Signed-off-by Ferruh Yigit <[email protected]>
Quoted 29 lines
--- drivers/net/netvsc/hn_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/netvsc/hn_rxtx.c +1
-1@@ -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;drivers/net/netvsc/hn_rxtx.c +2
-2struct 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;
Quoted 3 lines
if (
unlikely(data_len < RTE_ETHER_HDR_LEN))
--
2.25.4
Kindest regards
Raslan Darawsheh
Quoted 2 lines · On Tue, 8 Sep 2020 11:06:42 +0100 Ferruh Yigit <[email protected]> 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.
Quoted 8 lines · Stephen Hemminger
Quoted 2 lines · On Tue, 8 Sep 2020 11:06:42 +0100 Ferruh Yigit <[email protected]> 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:
Applied to dpdk-next-net/main, thanks.
Quoted 11 lines · Ferruh Yigit
'
__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 fromhost")
Reported-by Raslan Darawsheh <[email protected]>Signed-off-by Ferruh Yigit <[email protected]>
Quoted 33 lines
--- drivers/net/netvsc/hn_rxtx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/net/netvsc/hn_rxtx.c +3
-3@@ -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