aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fuse
diff options
context:
space:
mode:
authorKirill Tkhai <ktkhai@virtuozzo.com>2018-09-25 05:28:55 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2018-09-28 10:43:21 -0400
commitbc78abbd55dd28e2287ec6d6502b842321a17c87 (patch)
tree855aa7c8235688bb2ba0eed8ea56d942bea1c674 /fs/fuse
parent6bf4ca7fbc85d80446ac01c0d1d77db4d91a6d84 (diff)
fuse: Fix use-after-free in fuse_dev_do_read()
We may pick freed req in this way: [cpu0] [cpu1] fuse_dev_do_read() fuse_dev_do_write() list_move_tail(&req->list, ...); ... spin_unlock(&fpq->lock); ... ... request_end(fc, req); ... fuse_put_request(fc, req); if (test_bit(FR_INTERRUPTED, ...)) queue_interrupt(fiq, req); Fix that by keeping req alive until we finish all manipulations. Reported-by: syzbot+4e975615ca01f2277bdd@syzkaller.appspotmail.com Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Fixes: 46c34a348b0a ("fuse: no fc->lock for pqueue parts") Cc: <stable@vger.kernel.org> # v4.2
Diffstat (limited to 'fs/fuse')
-rw-r--r--fs/fuse/dev.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 11ea2c4a38ab..675caed3e655 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1311,12 +1311,14 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
1311 goto out_end; 1311 goto out_end;
1312 } 1312 }
1313 list_move_tail(&req->list, &fpq->processing); 1313 list_move_tail(&req->list, &fpq->processing);
1314 __fuse_get_request(req);
1314 spin_unlock(&fpq->lock); 1315 spin_unlock(&fpq->lock);
1315 set_bit(FR_SENT, &req->flags); 1316 set_bit(FR_SENT, &req->flags);
1316 /* matches barrier in request_wait_answer() */ 1317 /* matches barrier in request_wait_answer() */
1317 smp_mb__after_atomic(); 1318 smp_mb__after_atomic();
1318 if (test_bit(FR_INTERRUPTED, &req->flags)) 1319 if (test_bit(FR_INTERRUPTED, &req->flags))
1319 queue_interrupt(fiq, req); 1320 queue_interrupt(fiq, req);
1321 fuse_put_request(fc, req);
1320 1322
1321 return reqsize; 1323 return reqsize;
1322 1324