All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fuse: Fix use-after-free in fuse_dev_do_write()
@ 2018-09-25  9:52 Kirill Tkhai
  2018-10-01  9:26 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Kirill Tkhai @ 2018-09-25  9:52 UTC (permalink / raw)
  To: miklos, dvyukov, syzbot+4e975615ca01f2277bdd, linux-fsdevel,
	linux-kernel, ktkhai

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

Keep it alive till we finish touch its memory.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/dev.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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,
 
 	/* Is it an interrupt reply? */
 	if (req->intr_unique == oh.unique) {
+		__fuse_get_request(req);
 		spin_unlock(&fpq->lock);
 
 		err = -EINVAL;
-		if (nbytes != sizeof(struct fuse_out_header))
+		if (nbytes != sizeof(struct fuse_out_header)) {
+			fuse_put_request(fc, req);
 			goto err_finish;
+		}
 
 		if (oh.error == -ENOSYS)
 			fc->no_interrupt = 1;
 		else if (oh.error == -EAGAIN)
 			queue_interrupt(&fc->iq, req);
+		fuse_put_request(fc, req);
 
 		fuse_copy_finish(cs);
 		return nbytes;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fuse: Fix use-after-free in fuse_dev_do_write()
  2018-09-25  9:52 [PATCH] fuse: Fix use-after-free in fuse_dev_do_write() Kirill Tkhai
@ 2018-10-01  9:26 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2018-10-01  9:26 UTC (permalink / raw)
  To: Kirill Tkhai; +Cc: Dmitry Vyukov, syzbot, linux-fsdevel, linux-kernel

On Tue, Sep 25, 2018 at 11:52 AM, Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
> After we found req in request_find() and released the lock,
> everything may happen with the req in parallel.
>
> Keep it alive till we finish touch its memory.
>
> Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>

Applied.

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-01  9:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-25  9:52 [PATCH] fuse: Fix use-after-free in fuse_dev_do_write() Kirill Tkhai
2018-10-01  9:26 ` Miklos Szeredi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.