Skip to content

Commit fd42bfd

Browse files
Paul DurrantJakub Kicinski
authored andcommitted
xen-netback: avoid race that can lead to NULL pointer dereference
In function xenvif_disconnect_queue(), the value of queue->rx_irq is zeroed *before* queue->task is stopped. Unfortunately that task may call notify_remote_via_irq(queue->rx_irq) and calling that function with a zero value results in a NULL pointer dereference in evtchn_from_irq(). This patch simply re-orders things, stopping all tasks before zero-ing the irq values, thereby avoiding the possibility of the race. Fixes: 2ac061c ("xen/netback: cleanup init and deinit code") Signed-off-by: Paul Durrant <pdurrant@amazon.com> Acked-by: Wei Liu <wei.liu@kernel.org> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
1 parent 858ce8c commit fd42bfd

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎drivers/net/xen-netback/interface.c‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -628,18 +628,6 @@ int xenvif_connect_ctrl(struct xenvif *vif, grant_ref_t ring_ref,
628628

629629
static void xenvif_disconnect_queue(struct xenvif_queue *queue)
630630
{
631-
if (queue->tx_irq) {
632-
unbind_from_irqhandler(queue->tx_irq, queue);
633-
if (queue->tx_irq == queue->rx_irq)
634-
queue->rx_irq = 0;
635-
queue->tx_irq = 0;
636-
}
637-
638-
if (queue->rx_irq) {
639-
unbind_from_irqhandler(queue->rx_irq, queue);
640-
queue->rx_irq = 0;
641-
}
642-
643631
if (queue->task) {
644632
kthread_stop(queue->task);
645633
queue->task = NULL;
@@ -655,6 +643,18 @@ static void xenvif_disconnect_queue(struct xenvif_queue *queue)
655643
queue->napi.poll = NULL;
656644
}
657645

646+
if (queue->tx_irq) {
647+
unbind_from_irqhandler(queue->tx_irq, queue);
648+
if (queue->tx_irq == queue->rx_irq)
649+
queue->rx_irq = 0;
650+
queue->tx_irq = 0;
651+
}
652+
653+
if (queue->rx_irq) {
654+
unbind_from_irqhandler(queue->rx_irq, queue);
655+
queue->rx_irq = 0;
656+
}
657+
658658
xenvif_unmap_frontend_data_rings(queue);
659659
}
660660

0 commit comments

Comments
 (0)