Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752368AbdG1PQh (ORCPT ); Fri, 28 Jul 2017 11:16:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:52750 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751991AbdG1PQg (ORCPT ); Fri, 28 Jul 2017 11:16:36 -0400 Subject: Re: [PATCH] xen: avoid deadlock in xenbus To: Boris Ostrovsky , linux-kernel@vger.kernel.org, xen-devel@lists.xenproject.org References: <20170728145355.17258-1-jgross@suse.com> <71819268-dd53-a60f-5759-b3ae1ce486d4@oracle.com> From: Juergen Gross Message-ID: <09616301-1587-d5d5-a1dd-10ea74992339@suse.com> Date: Fri, 28 Jul 2017 17:16:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <71819268-dd53-a60f-5759-b3ae1ce486d4@oracle.com> Content-Type: text/plain; charset=windows-1252 Content-Language: de-DE Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1188 Lines: 44 On 28/07/17 17:14, Boris Ostrovsky wrote: > 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 > > Reviewed-by: Boris Ostrovsky > > +stable? As this problem is purely theoretical, I don't think the patch is appropriate for stable (at least the stable rules tell me so). Juergen