DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] librte_port: fix the buffer overflow for ring writer
@ 2016-04-11 17:55 Jasvinder Singh
  2016-04-11 20:35 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Jasvinder Singh @ 2016-04-11 17:55 UTC (permalink / raw)
  To: dev; +Cc: cristian.dumitrescu

Fixes the buffer overflow that occurs due to following;

1. When the input packet burst does not meet the conditions: (a) being
contiguous (first n bits set in pkts_mask, all the other bits cleared)
and (b) containing a full burst, i.e. at least tx_burst_sz packets
(n >= tx_burst_size). This is the slow(er) code path taken when local
variable expr != 0.
2. There are some packets already in the buffer.
3. The number of packets in the incoming burst (i.e. popcount(pkts_mask))
plus the number of packets already in the buffer exceeds the buffer size
(RTE_PORT_IN_BURST_SIZE_MAX, i.e. 64).

Fixes: bf6931b242f7 ("port: ring")
Fixes: 5f4cd47309d6 ("port: add ring writer nodrop")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 lib/librte_port/rte_port_ring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/librte_port/rte_port_ring.c b/lib/librte_port/rte_port_ring.c
index d36e12d..3b9d3d0 100644
--- a/lib/librte_port/rte_port_ring.c
+++ b/lib/librte_port/rte_port_ring.c
@@ -179,7 +179,7 @@ rte_port_ring_reader_stats_read(void *port,
 struct rte_port_ring_writer {
 	struct rte_port_out_stats stats;
 
-	struct rte_mbuf *tx_buf[RTE_PORT_IN_BURST_SIZE_MAX];
+	struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_ring *ring;
 	uint32_t tx_burst_sz;
 	uint32_t tx_buf_count;
@@ -447,7 +447,7 @@ rte_port_ring_writer_stats_read(void *port,
 struct rte_port_ring_writer_nodrop {
 	struct rte_port_out_stats stats;
 
-	struct rte_mbuf *tx_buf[RTE_PORT_IN_BURST_SIZE_MAX];
+	struct rte_mbuf *tx_buf[2 * RTE_PORT_IN_BURST_SIZE_MAX];
 	struct rte_ring *ring;
 	uint32_t tx_burst_sz;
 	uint32_t tx_buf_count;
-- 
2.5.5

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

* Re: [dpdk-dev] [PATCH] librte_port: fix the buffer overflow for ring writer
  2016-04-11 17:55 [dpdk-dev] [PATCH] librte_port: fix the buffer overflow for ring writer Jasvinder Singh
@ 2016-04-11 20:35 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2016-04-11 20:35 UTC (permalink / raw)
  To: Jasvinder Singh; +Cc: dev, cristian.dumitrescu

2016-04-11 18:55, Jasvinder Singh:
> Fixes the buffer overflow that occurs due to following;
> 
> 1. When the input packet burst does not meet the conditions: (a) being
> contiguous (first n bits set in pkts_mask, all the other bits cleared)
> and (b) containing a full burst, i.e. at least tx_burst_sz packets
> (n >= tx_burst_size). This is the slow(er) code path taken when local
> variable expr != 0.
> 2. There are some packets already in the buffer.
> 3. The number of packets in the incoming burst (i.e. popcount(pkts_mask))
> plus the number of packets already in the buffer exceeds the buffer size
> (RTE_PORT_IN_BURST_SIZE_MAX, i.e. 64).
> 
> Fixes: bf6931b242f7 ("port: ring")
> Fixes: 5f4cd47309d6 ("port: add ring writer nodrop")
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied, thanks

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

end of thread, other threads:[~2016-04-11 20:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-11 17:55 [dpdk-dev] [PATCH] librte_port: fix the buffer overflow for ring writer Jasvinder Singh
2016-04-11 20:35 ` Thomas Monjalon

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