linux/drivers/xen/xenbus
Juergen Gross 529871bb3c xen: avoid deadlock in xenbus
When starting the xenwatch thread a theoretical deadlock situation is
possible:

xs_init() contains:

    task = kthread_run(xenwatch_thread, NULL, "xenwatch");
    if (IS_ERR(task))
        return PTR_ERR(task);
    xenwatch_pid = task->pid;

And xenwatch_thread() does:

    mutex_lock(&xenwatch_mutex);
    ...
    event->handle->callback();
    ...
    mutex_unlock(&xenwatch_mutex);

The callback could call unregister_xenbus_watch() which does:

    ...
    if (current->pid != xenwatch_pid)
        mutex_lock(&xenwatch_mutex);
    ...

In case a watch is firing before xenwatch_pid could be set and the
callback of that watch unregisters a watch, then a self-deadlock would
occur.

Avoid this by setting xenwatch_pid in xenwatch_thread().

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
2017-08-11 16:45:56 +02:00
..
Makefile xen: Add xenbus_backend device 2011-12-16 13:29:41 -05:00
xenbus.h xen: optimize xenbus driver for multiple concurrent xenstore accesses 2017-02-09 11:26:49 -05:00
xenbus_client.c xen: modify xenstore watch event interface 2017-02-09 11:26:49 -05:00
xenbus_comms.c xen: avoid deadlock in xenbus driver 2017-06-25 13:11:22 +02:00
xenbus_dev_backend.c xen: clean up xenbus internal headers 2017-02-09 11:26:49 -05:00
xenbus_dev_frontend.c xenbus: remove transaction holder from list before freeing 2017-04-04 10:11:06 -04:00
xenbus_probe.c xen: modify xenstore watch event interface 2017-02-09 11:26:49 -05:00
xenbus_probe_backend.c xen: modify xenstore watch event interface 2017-02-09 11:26:49 -05:00
xenbus_probe_frontend.c xen: modify xenstore watch event interface 2017-02-09 11:26:49 -05:00
xenbus_xs.c xen: avoid deadlock in xenbus 2017-08-11 16:45:56 +02:00