From: David Vrabel <david.vrabel@citrix.com>
To: <netdev@vger.kernel.org>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>,
David Vrabel <david.vrabel@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCHv2 3/3] xen-netback: free queues after freeing the net device
Date: Fri, 15 Jan 2016 14:55:36 +0000 [thread overview]
Message-ID: <1452869736-20282-4-git-send-email-david.vrabel@citrix.com> (raw)
In-Reply-To: <1452869736-20282-1-git-send-email-david.vrabel@citrix.com>
If a queue still has a NAPI instance added to the net device, freeing
the queues early results in a use-after-free.
The shouldn't ever happen because we disconnect and tear down all queues
before freeing the net device, but doing this makes it obviously safe.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
---
drivers/net/xen-netback/interface.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 3bba6ce..f5231a2 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -685,22 +685,16 @@ void xenvif_deinit_queue(struct xenvif_queue *queue)
void xenvif_free(struct xenvif *vif)
{
- struct xenvif_queue *queue = NULL;
+ struct xenvif_queue *queues = vif->queues;
unsigned int num_queues = vif->num_queues;
unsigned int queue_index;
unregister_netdev(vif->dev);
-
- for (queue_index = 0; queue_index < num_queues; ++queue_index) {
- queue = &vif->queues[queue_index];
- xenvif_deinit_queue(queue);
- }
-
- vfree(vif->queues);
- vif->queues = NULL;
- vif->num_queues = 0;
-
free_netdev(vif->dev);
+ for (queue_index = 0; queue_index < num_queues; ++queue_index)
+ xenvif_deinit_queue(&queues[queue_index]);
+ vfree(queues);
+
module_put(THIS_MODULE);
}
--
2.1.4
next prev parent reply other threads:[~2016-01-15 14:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 14:55 [PATCHv2 0/3 net] xen-netback: use skb to determine number of required (etc.) David Vrabel
2016-01-15 14:55 ` [PATCHv2 1/3] xen-netback: use skb to determine number of required guest Rx requests David Vrabel
2016-01-15 14:55 ` [PATCHv2 2/3] xen-netback: delete NAPI instance when queue fails to initialize David Vrabel
2016-01-15 14:55 ` David Vrabel [this message]
2016-01-15 20:13 ` [PATCHv2 0/3 net] xen-netback: use skb to determine number of required (etc.) David Miller
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=1452869736-20282-4-git-send-email-david.vrabel@citrix.com \
--to=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=netdev@vger.kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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).