提交 e8e17b1b 编写于 作者: K Kirill Tkhai 提交者: Greg Kroah-Hartman

fuse: Fix use-after-free in fuse_dev_do_read()

commit bc78abbd55dd28e2287ec6d6502b842321a17c87 upstream.

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: NKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
Fixes: 46c34a34 ("fuse: no fc->lock for pqueue parts")
Cc: <stable@vger.kernel.org> # v4.2
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 cbd6cfd2
...@@ -1311,12 +1311,14 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file, ...@@ -1311,12 +1311,14 @@ static ssize_t fuse_dev_do_read(struct fuse_dev *fud, struct file *file,
goto out_end; goto out_end;
} }
list_move_tail(&req->list, &fpq->processing); list_move_tail(&req->list, &fpq->processing);
__fuse_get_request(req);
spin_unlock(&fpq->lock); spin_unlock(&fpq->lock);
set_bit(FR_SENT, &req->flags); set_bit(FR_SENT, &req->flags);
/* matches barrier in request_wait_answer() */ /* matches barrier in request_wait_answer() */
smp_mb__after_atomic(); smp_mb__after_atomic();
if (test_bit(FR_INTERRUPTED, &req->flags)) if (test_bit(FR_INTERRUPTED, &req->flags))
queue_interrupt(fiq, req); queue_interrupt(fiq, req);
fuse_put_request(fc, req);
return reqsize; return reqsize;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册