Skip to content

Commit 107866a

Browse files
roygerjgross1
authored andcommitted
xen-netback: take a reference to the RX task thread
Do this in order to prevent the task from being freed if the thread returns (which can be triggered by the frontend) before the call to kthread_stop done as part of the backend tear down. Not taking the reference will lead to a use-after-free in that scenario. Such reference was taken before but dropped as part of the rework done in 2ac061c. Reintroduce the reference taking and add a comment this time explaining why it's needed. This is XSA-374 / CVE-2021-28691. Fixes: 2ac061c ('xen/netback: cleanup init and deinit code') Signed-off-by: Roger Pau Monné <[email protected]> Cc: [email protected] Reviewed-by: Jan Beulich <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent c81d3d2 commit 107866a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/net/xen-netback/interface.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ static void xenvif_disconnect_queue(struct xenvif_queue *queue)
684684
{
685685
if (queue->task) {
686686
kthread_stop(queue->task);
687+
put_task_struct(queue->task);
687688
queue->task = NULL;
688689
}
689690

@@ -745,6 +746,11 @@ int xenvif_connect_data(struct xenvif_queue *queue,
745746
if (IS_ERR(task))
746747
goto kthread_err;
747748
queue->task = task;
749+
/*
750+
* Take a reference to the task in order to prevent it from being freed
751+
* if the thread function returns before kthread_stop is called.
752+
*/
753+
get_task_struct(task);
748754

749755
task = kthread_run(xenvif_dealloc_kthread, queue,
750756
"%s-dealloc", queue->name);

0 commit comments

Comments
 (0)