From: "Timmons C. Player" <timmons.player@spirent.com>
To: linville@tuxdriver.com
Cc: dev@dpdk.org, "Timmons C. Player" <timmons.player@spirent.com>
Subject: [dpdk-dev] [PATCH] net/af_packet: fix fd use after free
Date: Thu, 5 Jan 2017 09:33:35 -0500 [thread overview]
Message-ID: <1483626815-476-1-git-send-email-timmons.player@spirent.com> (raw)
When using the same file descriptor for both rx and tx, the
eth_dev_stop function would close the same fd twice. This
change prevents that from happening.
Signed-off-by: Timmons C. Player <timmons.player@spirent.com>
---
drivers/net/af_packet/rte_eth_af_packet.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
index 2951f86..c44b8b9 100644
--- a/drivers/net/af_packet/rte_eth_af_packet.c
+++ b/drivers/net/af_packet/rte_eth_af_packet.c
@@ -261,9 +261,16 @@ eth_dev_stop(struct rte_eth_dev *dev)
sockfd = internals->rx_queue[i].sockfd;
if (sockfd != -1)
close(sockfd);
- sockfd = internals->tx_queue[i].sockfd;
- if (sockfd != -1)
- close(sockfd);
+
+ /* Prevent use after free in case tx fd == rx fd */
+ if (sockfd != internals->tx_queue[i].sockfd) {
+ sockfd = internals->tx_queue[i].sockfd;
+ if (sockfd != -1)
+ close(sockfd);
+ }
+
+ internals->rx_queue[i].sockfd = -1;
+ internals->tx_queue[i].sockfd = -1;
}
dev->data->dev_link.link_status = ETH_LINK_DOWN;
--
2.7.4
next reply other threads:[~2017-01-05 14:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-05 14:33 Timmons C. Player [this message]
2017-01-09 11:55 ` Ferruh Yigit
2017-01-09 12:04 ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1483626815-476-1-git-send-email-timmons.player@spirent.com \
--to=timmons.player@spirent.com \
--cc=dev@dpdk.org \
--cc=linville@tuxdriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).