Skip to contentSkip to conversation

Please apply "xen-netback: delete NAPI instance when queue fails to initialize" to v4.4.y

PATCH SeongJae Park 2 participants 3 messages Feb 24, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

This is a request for merge of upstream commit 4a658527271b ("xen-netback:
delete NAPI instance when queue fails to initialize") on v4.4.y tree.

If 'xenvif_connect()' fails after successful 'netif_napi_add()', the napi is not cleaned up. Because 'create_queues()' frees the queues in its error handling code, if the 'xenvif_free()' is called for the vif, use-after-free occurs. The upstream commit fixes the problem by cleaning up the napi in the 'xenvif_connect()'.

Attaching the original patch below for your convenience.

Thanks,
SeongJae Park

==================================== >8 ======================================= From 4a658527271bce43afb1cf4feec89afe6716ca59 Mon Sep 17 00:00:00 2001
From: David Vrabel <[email protected]>
Date: Fri, 15 Jan 2016 14:55:35 +0000
Subject: [PATCH] xen-netback: delete NAPI instance when queue fails to
initialize

When xenvif_connect() fails it may leave a stale NAPI instance added to the device. Make sure we delete it in the error path.

---
 drivers/net/xen-netback/interface.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/xen-netback/interface.c +1 -0
index e7bd63eb2876..3bba6ceee132 100644
@@ -615,6 +615,7 @@ int xenvif_connect(struct xenvif_queue *queue, unsigned long tx_ring_ref,
 	queue->tx_irq = 0;
 err_unmap:
 	xenvif_unmap_frontend_rings(queue);
+	netif_napi_del(&queue->napi);
 err:
 	module_put(THIS_MODULE);
 	return err;
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 10 lines · SeongJae Park

This is a request for merge of upstream commit 4a658527271b ("xen-netback:
delete NAPI instance when queue fails to initialize") on v4.4.y tree.

If 'xenvif_connect()' fails after successful 'netif_napi_add()', the napi is not cleaned up. Because 'create_queues()' frees the queues in its error handling code, if the 'xenvif_free()' is called for the vif, use-after-free occurs. The upstream commit fixes the problem by cleaning up the napi in the 'xenvif_connect()'.

Attaching the original patch below for your convenience.

The original patch does not apply cleanly.

Quoted 1 line

What was tested?

I backported the patch, but next time, please provide the patch that will work properly.

greg k-h

#2 lore raw
Quoted 10 lines · On Wed, 24 Feb 2021 18:21:09 +0100 Greg KH <[email protected]> wrote:
Quoted 9 lines · SeongJae Park

This is a request for merge of upstream commit 4a658527271b ("xen-netback:
delete NAPI instance when queue fails to initialize") on v4.4.y tree.

If 'xenvif_connect()' fails after successful 'netif_napi_add()', the napi is not cleaned up. Because 'create_queues()' frees the queues in its error handling code, if the 'xenvif_free()' is called for the vif, use-after-free occurs. The upstream commit fixes the problem by cleaning up the napi in the 'xenvif_connect()'.

Quoted 3 lines
Quoted 1 line

Attaching the original patch below for your convenience.

The original patch does not apply cleanly.

I tested the commit is cleanly applicable with 'git cherry-pick' before posting this. I just tried 'git format-patch ... && git am ...' and confirmed it doesn't work. Sorry, my fault.

Quoted 4 lines
Quoted 2 lines

What was tested?

We confirmed the unmodified v4.4.y kernel crashes on a stress test that repeatedly doing netdev attach/detach, while the patch applied version doesn't.

Quoted 3 lines

I backported the patch, but next time, please provide the patch that will work properly.

Thanks, and apology for the inconvenience. I will do the check with posting patch again rather than only 'git cherry-pick' from next time.

Thanks,
SeongJae Park

Quoted 2 lines

greg k-h