Commit ab962e91 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Greg Kroah-Hartman

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

commit d2d2d4fb upstream.

After we found req in request_find() and released the lock,
everything may happen with the req in parallel:

cpu0                              cpu1
fuse_dev_do_write()               fuse_dev_do_write()
  req = request_find(fpq, ...)    ...
  spin_unlock(&fpq->lock)         ...
  ...                             req = request_find(fpq, oh.unique)
  ...                             spin_unlock(&fpq->lock)
  queue_interrupt(&fc->iq, req);   ...
  ...                              ...
  ...                              ...
  request_end(fc, req);
    fuse_put_request(fc, req);
  ...                              queue_interrupt(&fc->iq, req);
Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Fixes: 46c34a34 ("fuse: no fc->lock for pqueue parts")
Cc: <stable@vger.kernel.org> # v4.2
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d94b3a23
...@@ -1874,16 +1874,20 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, ...@@ -1874,16 +1874,20 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud,
/* Is it an interrupt reply? */ /* Is it an interrupt reply? */
if (req->intr_unique == oh.unique) { if (req->intr_unique == oh.unique) {
__fuse_get_request(req);
spin_unlock(&fpq->lock); spin_unlock(&fpq->lock);
err = -EINVAL; err = -EINVAL;
if (nbytes != sizeof(struct fuse_out_header)) if (nbytes != sizeof(struct fuse_out_header)) {
fuse_put_request(fc, req);
goto err_finish; goto err_finish;
}
if (oh.error == -ENOSYS) if (oh.error == -ENOSYS)
fc->no_interrupt = 1; fc->no_interrupt = 1;
else if (oh.error == -EAGAIN) else if (oh.error == -EAGAIN)
queue_interrupt(&fc->iq, req); queue_interrupt(&fc->iq, req);
fuse_put_request(fc, req);
fuse_copy_finish(cs); fuse_copy_finish(cs);
return nbytes; return nbytes;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment