]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
fuse: fix double request_end()
authorMiklos Szeredi <mszeredi@redhat.com>
Thu, 26 Jul 2018 14:13:11 +0000 (16:13 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Tue, 23 Apr 2019 15:51:47 +0000 (17:51 +0200)
BugLink: https://bugs.launchpad.net/bugs/1824553
Refcounting of request is broken when fuse_abort_conn() is called and
request is on the fpq->io list:

 - ref is taken too late
 - then it is not dropped

Fixes: 0d8e84b0432b ("fuse: simplify request abort")
Cc: <stable@vger.kernel.org> # v4.2
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
(cherry picked from commit 87114373ea507895a62afb10d2910bd9adac35a8)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
fs/fuse/dev.c

index c3912517338f3f021605b8f1d43f3a739bc3fad8..c973006eaf90cba9a50ed660cc5334a08ecf8b5e 100644 (file)
@@ -368,7 +368,7 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
        struct fuse_iqueue *fiq = &fc->iq;
 
        if (test_and_set_bit(FR_FINISHED, &req->flags))
-               return;
+               goto out_put_req;
 
        spin_lock(&fiq->waitq.lock);
        list_del_init(&req->intr_entry);
@@ -397,6 +397,7 @@ static void request_end(struct fuse_conn *fc, struct fuse_req *req)
        wake_up(&req->waitq);
        if (req->end)
                req->end(fc, req);
+out_put_req:
        fuse_put_request(fc, req);
 }
 
@@ -2110,6 +2111,7 @@ void fuse_abort_conn(struct fuse_conn *fc)
                                set_bit(FR_ABORTED, &req->flags);
                                if (!test_bit(FR_LOCKED, &req->flags)) {
                                        set_bit(FR_PRIVATE, &req->flags);
+                                       __fuse_get_request(req);
                                        list_move(&req->list, &to_end1);
                                }
                                spin_unlock(&req->waitq.lock);
@@ -2136,7 +2138,6 @@ void fuse_abort_conn(struct fuse_conn *fc)
 
                while (!list_empty(&to_end1)) {
                        req = list_first_entry(&to_end1, struct fuse_req, list);
-                       __fuse_get_request(req);
                        list_del_init(&req->list);
                        request_end(fc, req);
                }