Skip to content

Commit 1c72871

Browse files
wipaweljgross1
authored andcommitted
xen-blkback: set ring->xenblkd to NULL after kthread_stop()
When xen_blkif_disconnect() is called, the kernel thread behind the block interface is stopped by calling kthread_stop(ring->xenblkd). The ring->xenblkd thread pointer being non-NULL determines if the thread has been already stopped. Normally, the thread's function xen_blkif_schedule() sets the ring->xenblkd to NULL, when the thread's main loop ends. However, when the thread has not been started yet (i.e. wake_up_process() has not been called on it), the xen_blkif_schedule() function would not be called yet. In such case the kthread_stop() call returns -EINTR and the ring->xenblkd remains dangling. When this happens, any consecutive call to xen_blkif_disconnect (for example in frontend_changed() callback) leads to a kernel crash in kthread_stop() (e.g. NULL pointer dereference in exit_creds()). This is XSA-350. Cc: <[email protected]> # 4.12 Fixes: a24fa22 ("xen/blkback: don't use xen_blkif_get() in xen-blkback kthread") Reported-by: Olivier Benjamin <[email protected]> Reported-by: Pawel Wieczorkiewicz <[email protected]> Signed-off-by: Pawel Wieczorkiewicz <[email protected]> Reviewed-by: Julien Grall <[email protected]> Reviewed-by: Juergen Gross <[email protected]> Signed-off-by: Juergen Gross <[email protected]>
1 parent 9996bd4 commit 1c72871

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/block/xen-blkback/xenbus.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
274274

275275
if (ring->xenblkd) {
276276
kthread_stop(ring->xenblkd);
277+
ring->xenblkd = NULL;
277278
wake_up(&ring->shutdown_wq);
278279
}
279280

0 commit comments

Comments
 (0)