From: David Vrabel Date: Fri, 9 Dec 2016 14:41:13 +0000 (+0000) Subject: xenbus: fix deadlock on writes to /proc/xen/xenbus X-Git-Tag: v4.1.12-92~13^2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=33bcf48c7febdcf77a0abc551ca8c228ab00b22b;p=users%2Fjedix%2Flinux-maple.git xenbus: fix deadlock on writes to /proc/xen/xenbus /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 Signed-off-by: Juergen Gross Orabug: 25425387 (cherry picked from commit 581d21a2d02a798ee34e56dbfa13f891b3a90c30) Jira: OCC-36718 Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Chuck Anderson --- diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c index 32f8186ca92f0..ee10d8e6261f0 100644 --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -540,6 +540,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;