From patchwork Fri Dec 9 14:41:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Vrabel X-Patchwork-Id: 9468419 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A19DF607D8 for ; Fri, 9 Dec 2016 14:43:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 909EB28592 for ; Fri, 9 Dec 2016 14:43:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82F36284C7; Fri, 9 Dec 2016 14:43:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04255284C7 for ; Fri, 9 Dec 2016 14:43:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFMMU-0006B0-8G; Fri, 09 Dec 2016 14:41:22 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cFMMT-0006Au-12 for xen-devel@lists.xenproject.org; Fri, 09 Dec 2016 14:41:21 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id EC/5C-28947-092CA485; Fri, 09 Dec 2016 14:41:20 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsXitHRDpG7/Ia8 Ig4dzjCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owT694zF8zgqFj8expzA2MbexcjJ4eEgL/E urczWEFsNgEdicdLZgDFOThEBFQkbu81AAkzC1RJXLn0GaxEWMBVYs/v12CtLEAlz1fuALN5B dwlrp3fzwwxUk7i/PGfYLYQUM3HtatYIWoEJU7OfMICMVNC4uCLF8wTGLlnIUnNQpJawMi0il G9OLWoLLVI11IvqSgzPaMkNzEzR9fQwFgvN7W4ODE9NScxqVgvOT93EyMwEOoZGBh3ML7+6XS IUZKDSUmUt5jJK0KILyk/pTIjsTgjvqg0J7X4EKMMB4eSBG/RAaCcYFFqempFWmYOMCRh0hIc PEoivG4HgdK8xQWJucWZ6RCpU4y6HNOeLX7KJMSSl5+XKiXOuwKkSACkKKM0D24ELD4uMcpKC fMyMjAwCPEUpBblZpagyr9iFOdgVBLmvQZyCU9mXgncpldARzABHTHvhjvIESWJCCmpBkaXPU /+6RnuzXl3Jfuw7vtVnZ6J3wsdzpxTTzjCdYhne0PvPNFzsboH3TMy/VbeEnm9YsNvjsabZhk yWac8clS5TxekHzyx+NebqN0/1h7zndasIti1zfx0Ef/qKZJ18zmWZOqxvk4vYn+YfS/CZnVy Tto9uYS9zjI5yWWVD+6fj/i8+qiI7ColluKMREMt5qLiRABVPNDligIAAA== X-Env-Sender: prvs=144620623=david.vrabel@citrix.com X-Msg-Ref: server-15.tower-31.messagelabs.com!1481294478!71331517!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8071 invoked from network); 9 Dec 2016 14:41:19 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-15.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 9 Dec 2016 14:41:19 -0000 X-IronPort-AV: E=Sophos;i="5.33,324,1477958400"; d="scan'208";a="393960805" From: David Vrabel To: Date: Fri, 9 Dec 2016 14:41:13 +0000 Message-ID: <1481294473-32203-1-git-send-email-david.vrabel@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 Cc: Juergen Gross , Boris Ostrovsky , David Vrabel Subject: [Xen-devel] [PATCHv6] xenbus: fix deadlock on writes to /proc/xen/xenbus X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP /proc/xen/xenbus does not work correctly. A read blocked waiting for a xenstore message holds the mutex needed for atomic file position updates. This blocks any writes on the same file handle, which can deadlock if the write is needed to unblock the read. Clear FMODE_ATOMIC_POS when opening this device to always get character device like sematics. Signed-off-by: David Vrabel Reviewed-by: Juergen Gross --- v6: - clear flag after calling nonseekable_open(). --- drivers/xen/xenbus/xenbus_dev_frontend.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index 1e8be12..6c0ead4 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -538,6 +538,8 @@ static int xenbus_file_open(struct inode *inode, struct file *filp) nonseekable_open(inode, filp); + filp->f_mode &= ~FMODE_ATOMIC_POS; /* cdev-style semantics */ + u = kzalloc(sizeof(*u), GFP_KERNEL); if (u == NULL) return -ENOMEM;