diff options
author | Kirill Tkhai <ktkhai@virtuozzo.com> | 2018-09-25 05:52:42 -0400 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2018-09-28 10:43:21 -0400 |
commit | d2d2d4fb1f54eff0f3faa9762d84f6446a4bc5d0 (patch) | |
tree | ddd35a1d08bab57bcd1b35e24f304958b17609f9 | |
parent | bc78abbd55dd28e2287ec6d6502b842321a17c87 (diff) |
fuse: Fix use-after-free in fuse_dev_do_write()
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: 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
-rw-r--r-- | fs/fuse/dev.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 675caed3e655..c2af8042f176 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -1877,16 +1877,20 @@ static ssize_t fuse_dev_do_write(struct fuse_dev *fud, | |||
1877 | 1877 | ||
1878 | /* Is it an interrupt reply? */ | 1878 | /* Is it an interrupt reply? */ |
1879 | if (req->intr_unique == oh.unique) { | 1879 | if (req->intr_unique == oh.unique) { |
1880 | __fuse_get_request(req); | ||
1880 | spin_unlock(&fpq->lock); | 1881 | spin_unlock(&fpq->lock); |
1881 | 1882 | ||
1882 | err = -EINVAL; | 1883 | err = -EINVAL; |
1883 | if (nbytes != sizeof(struct fuse_out_header)) | 1884 | if (nbytes != sizeof(struct fuse_out_header)) { |
1885 | fuse_put_request(fc, req); | ||
1884 | goto err_finish; | 1886 | goto err_finish; |
1887 | } | ||
1885 | 1888 | ||
1886 | if (oh.error == -ENOSYS) | 1889 | if (oh.error == -ENOSYS) |
1887 | fc->no_interrupt = 1; | 1890 | fc->no_interrupt = 1; |
1888 | else if (oh.error == -EAGAIN) | 1891 | else if (oh.error == -EAGAIN) |
1889 | queue_interrupt(&fc->iq, req); | 1892 | queue_interrupt(&fc->iq, req); |
1893 | fuse_put_request(fc, req); | ||
1890 | 1894 | ||
1891 | fuse_copy_finish(cs); | 1895 | fuse_copy_finish(cs); |
1892 | return nbytes; | 1896 | return nbytes; |