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

We may pick freed req in this way:

[cpu0]                                              [cpu1]
fuse_dev_do_read()                                  fuse_dev_do_write()
   list_move_tail(&req->list, &fpq->processing);      ...
   spin_unlock(&fpq->lock);                           ...
   ...                                                request_end(fc, req);
   ...                                                  fuse_put_request(fc, req);
   if (test_bit(FR_INTERRUPTED, &req->flags))
         queue_interrupt(fiq, req);

Fix that by keeping req alive till we finish all manipulations.

Reported-by: syzbot+4e975615ca01f2277bdd@syzkaller.appspotmail.com
Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/dev.c |    2 ++
 1 file changed, 2 insertions(+)

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,
 		goto out_end;
 	}
 	list_move_tail(&req->list, &fpq->processing);
+	__fuse_get_request(req);
 	spin_unlock(&fpq->lock);
 	set_bit(FR_SENT, &req->flags);
 	/* matches barrier in request_wait_answer() */
 	smp_mb__after_atomic();
 	if (test_bit(FR_INTERRUPTED, &req->flags))
 		queue_interrupt(fiq, req);
+	fuse_put_request(fc, req);
 
 	return reqsize;
 

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

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

On Tue, Sep 25, 2018 at 11:28 AM, Kirill Tkhai <ktkhai@virtuozzo.com> wrote:
> We may pick freed req in this way:
>
> [cpu0]                                              [cpu1]
> fuse_dev_do_read()                                  fuse_dev_do_write()
>    list_move_tail(&req->list, &fpq->processing);      ...
>    spin_unlock(&fpq->lock);                           ...
>    ...                                                request_end(fc, req);
>    ...                                                  fuse_put_request(fc, req);
>    if (test_bit(FR_INTERRUPTED, &req->flags))
>          queue_interrupt(fiq, req);
>
> Fix that by keeping req alive till we finish all manipulations.
>
> Reported-by: syzbot+4e975615ca01f2277bdd@syzkaller.appspotmail.com
> 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 16:02 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:28 [PATCH] fuse: Fix use-after-free in fuse_dev_do_read() Kirill Tkhai
2018-10-01  9:25 ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).