提交 107866a8 编写于 作者: R Roger Pau Monne 提交者: Juergen Gross

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
2ac061ce.

Reintroduce the reference taking and add a comment this time
explaining why it's needed.

This is XSA-374 / CVE-2021-28691.

Fixes: 2ac061ce ('xen/netback: cleanup init and deinit code')
Signed-off-by: NRoger Pau Monné <roger.pau@citrix.com>
Cc: stable@vger.kernel.org
Reviewed-by: NJan Beulich <jbeulich@suse.com>
Reviewed-by: NJuergen Gross <jgross@suse.com>
Signed-off-by: NJuergen Gross <jgross@suse.com>
上级 c81d3d24
...@@ -684,6 +684,7 @@ static void xenvif_disconnect_queue(struct xenvif_queue *queue) ...@@ -684,6 +684,7 @@ static void xenvif_disconnect_queue(struct xenvif_queue *queue)
{ {
if (queue->task) { if (queue->task) {
kthread_stop(queue->task); kthread_stop(queue->task);
put_task_struct(queue->task);
queue->task = NULL; queue->task = NULL;
} }
...@@ -745,6 +746,11 @@ int xenvif_connect_data(struct xenvif_queue *queue, ...@@ -745,6 +746,11 @@ int xenvif_connect_data(struct xenvif_queue *queue,
if (IS_ERR(task)) if (IS_ERR(task))
goto kthread_err; goto kthread_err;
queue->task = task; queue->task = task;
/*
* Take a reference to the task in order to prevent it from being freed
* if the thread function returns before kthread_stop is called.
*/
get_task_struct(task);
task = kthread_run(xenvif_dealloc_kthread, queue, task = kthread_run(xenvif_dealloc_kthread, queue,
"%s-dealloc", queue->name); "%s-dealloc", queue->name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册