All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fuse: fix use-after-free in fuse_direct_IO()
@ 2018-11-09 13:51 Lukas Czerner
  2018-11-09 14:57 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Lukas Czerner @ 2018-11-09 13:51 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: miklos

In async IO blocking case the additional reference to the io is taken for
it to survive fuse_aio_complete(). In non blocking case this additional
reference is not needed, however we still reference io to figure out
whether to wait for completion or not. This is wrong and will lead to
use-after-free. Fix it by storing blocking information in separate
variable.

This was spotted by KASAN when running generic/208 fstest.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Fixes: 744742d692e3 ("fuse: Add reference counting for fuse_io_priv")
Reported-by: Zorro Lang <zlang@redhat.com>
---
 fs/fuse/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index cc2121b37bf5..b52f9baaa3e7 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2924,10 +2924,12 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	}
 
 	if (io->async) {
+		bool blocking = io->blocking;
+
 		fuse_aio_complete(io, ret < 0 ? ret : 0, -1);
 
 		/* we have a non-extending, async request, so return */
-		if (!io->blocking)
+		if (!blocking)
 			return -EIOCBQUEUED;
 
 		wait_for_completion(&wait);
-- 
2.17.2

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

* Re: [PATCH] fuse: fix use-after-free in fuse_direct_IO()
  2018-11-09 13:51 [PATCH] fuse: fix use-after-free in fuse_direct_IO() Lukas Czerner
@ 2018-11-09 14:57 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2018-11-09 14:57 UTC (permalink / raw)
  To: Lukas Czerner; +Cc: linux-fsdevel

On Fri, Nov 9, 2018 at 2:51 PM, Lukas Czerner <lczerner@redhat.com> wrote:
> In async IO blocking case the additional reference to the io is taken for
> it to survive fuse_aio_complete(). In non blocking case this additional
> reference is not needed, however we still reference io to figure out
> whether to wait for completion or not. This is wrong and will lead to
> use-after-free. Fix it by storing blocking information in separate
> variable.
>
> This was spotted by KASAN when running generic/208 fstest.

Thanks, applied.

Miklos

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

end of thread, other threads:[~2018-11-10  0:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-09 13:51 [PATCH] fuse: fix use-after-free in fuse_direct_IO() Lukas Czerner
2018-11-09 14:57 ` 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.