]> git.baikalelectronics.ru Git - kernel.git/commit
xen-blkback: set ring->xenblkd to NULL after kthread_stop()
authorPawel Wieczorkiewicz <wipawel@amazon.de>
Mon, 14 Dec 2020 09:25:57 +0000 (10:25 +0100)
committerJuergen Gross <jgross@suse.com>
Mon, 14 Dec 2020 09:25:57 +0000 (10:25 +0100)
commit026f86fe0db3f8b42053a583a6810319f1ff89e5
treeb0e7d2bf03ffd53abb72301f5e6b08e40ec88c65
parentc814db55aca2e2755a1a1f442748561dd2a06249
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: <stable@vger.kernel.org> # 4.12
Fixes: bc219e1f9839 ("xen/blkback: don't use xen_blkif_get() in xen-blkback kthread")
Reported-by: Olivier Benjamin <oliben@amazon.com>
Reported-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de>
Reviewed-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
drivers/block/xen-blkback/xenbus.c