xenbus: fix deadlock on writes to /proc/xen/xenbus
PATCH v6 1/1 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.
---
v6:
- clear flag after calling nonseekable_open().
--- drivers/xen/xenbus/xenbus_dev_frontend.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/xen/xenbus/xenbus_dev_frontend.c +2 -0
@@ -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 ;
Signature · 7 lines
2.1.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Quoted 7 lines · David Vrabel
/proc/xen/xenbusdoes 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_POSwhen opening this device to always get character device like sematics.
"semantics". I can fix this when committing.
Quoted 2 lines
Signed-off-by David Vrabel <[email protected]>
Juergen
Quoted 13 lines
---
v6:
- clear flag after callingnonseekable_open().--- drivers/xen/xenbus/xenbus_dev_frontend.c | 2 ++ 1 file changed, 2 insertions(+)drivers/xen/xenbus/xenbus_dev_frontend.c +0
-0
drivers/xen/xenbus/xenbus_dev_frontend.c static int xenbus_file_open(struct inode *inode, struct file *filp) · line 545
Quoted 8 lines
drivers/xen/xenbus/xenbus_dev_frontend.c +2
-0@@ -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 ;
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Juergen Gross
maintainerQuoted 9 lines · David Vrabel
/proc/xen/xenbusdoes 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_POSwhen opening this device to always get character device like sematics.Signed-off-by David Vrabel <[email protected]>
Committed to xen/tip.git for-linus-4.10
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel