From: Miklos Szeredi Date: Thu, 26 Jul 2018 14:13:11 +0000 (+0200) Subject: fuse: fix unlocked access to processing queue X-Git-Tag: Ubuntu-4.15.0-49.53~84 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1011a05d99d431041dd6a577c3812be700d18fe9;p=mirror_ubuntu-bionic-kernel.git fuse: fix unlocked access to processing queue BugLink: https://bugs.launchpad.net/bugs/1824553 fuse_dev_release() assumes that it's the only one referencing the fpq->processing list, but that's not true, since fuse_abort_conn() can be doing the same without any serialization between the two. Fixes: c3696046beb3 ("fuse: separate pqueue for clones") Cc: # v4.2 Signed-off-by: Miklos Szeredi (cherry picked from commit 45ff350bbd9d0f0977ff270a0d427c71520c0c37) Signed-off-by: Andrea Righi Acked-by: Stefan Bader Acked-by: Kleber Sacilotto de Souza Signed-off-by: Kleber Sacilotto de Souza --- diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index c973006eaf90..b28cbc0532ce 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2155,9 +2155,15 @@ int fuse_dev_release(struct inode *inode, struct file *file) if (fud) { struct fuse_conn *fc = fud->fc; struct fuse_pqueue *fpq = &fud->pq; + LIST_HEAD(to_end); + spin_lock(&fpq->lock); WARN_ON(!list_empty(&fpq->io)); - end_requests(fc, &fpq->processing); + list_splice_init(&fpq->processing, &to_end); + spin_unlock(&fpq->lock); + + end_requests(fc, &to_end); + /* Are we the last open device? */ if (atomic_dec_and_test(&fc->dev_count)) { WARN_ON(fc->iq.fasync != NULL);