From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Juergen Gross <jgross@suse.com>,
linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org
Subject: Re: [PATCH] xen: avoid deadlock in xenbus
Date: Fri, 28 Jul 2017 11:14:59 -0400 [thread overview]
Message-ID: <71819268-dd53-a60f-5759-b3ae1ce486d4@oracle.com> (raw)
In-Reply-To: <20170728145355.17258-1-jgross@suse.com>
On 07/28/2017 10:53 AM, Juergen Gross wrote:
> 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>
+stable?
next prev parent reply other threads:[~2017-07-28 15:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-28 14:53 Juergen Gross
2017-07-28 15:14 ` Boris Ostrovsky [this message]
2017-07-28 15:16 ` Juergen Gross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=71819268-dd53-a60f-5759-b3ae1ce486d4@oracle.com \
--to=boris.ostrovsky@oracle.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®