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: v5.15~12062^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=581d21a2d02a798ee34e56dbfa13f891b3a90c30;p=platform%2Fkernel%2Flinux-starfive.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 --- 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;