patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH] ethdev: avoid undefined behaviour on configuration copying
@ 2019-11-19  8:22 Andrew Rybchenko
  2019-11-19 12:24 ` Ferruh Yigit
  2019-11-19 14:57 ` Ferruh Yigit
  0 siblings, 2 replies; 9+ messages in thread
From: Andrew Rybchenko @ 2019-11-19  8:22 UTC (permalink / raw)
  To: Thomas Monjalon, Ferruh Yigit; +Cc: dev, stable

memcpy() source and destination areas must not overlap and equal
pointers is the case which is really met, so handle it.

Fixes: 68b931bff287 ("ethdev: eliminate interim variable")
Cc: stable@dpdk.org

Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
slave_configure() in drivers/net/bonding calls rte_eth_dev_configure()
with &slave_eth_dev->data->dev_conf.

Alternative solution is to fix bonding and return error if dev_conf is
equal to &dev->data->dev_conf since usecase is unclear and callers
should not use dev->data.

 lib/librte_ethdev/rte_ethdev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index 8f48e8d659..8d2ce31a81 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1245,7 +1245,9 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	 * Copy the dev_conf parameter into the dev structure.
 	 * rte_eth_dev_info_get() requires dev_conf, copy it before dev_info get
 	 */
-	memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
+	if (dev_conf != &dev->data->dev_conf)
+		memcpy(&dev->data->dev_conf, dev_conf,
+		       sizeof(dev->data->dev_conf));
 
 	ret = rte_eth_dev_info_get(port_id, &dev_info);
 	if (ret != 0)
-- 
2.17.1


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

end of thread, other threads:[~2019-11-19 15:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-19  8:22 [dpdk-stable] [PATCH] ethdev: avoid undefined behaviour on configuration copying Andrew Rybchenko
2019-11-19 12:24 ` Ferruh Yigit
2019-11-19 12:36   ` Andrew Rybchenko
2019-11-19 13:19     ` Ferruh Yigit
2019-11-19 13:25       ` Andrew Rybchenko
2019-11-19 13:37       ` Ferruh Yigit
2019-11-19 13:59         ` Andrew Rybchenko
2019-11-19 14:57 ` Ferruh Yigit
2019-11-19 15:47   ` Ferruh Yigit

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