fuse: do not use iocb after it may have been freed
authorRobert Doebbelin <robert@quobyte.com>
Mon, 7 Mar 2016 08:50:56 +0000 (09:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:46:57 +0000 (00:46 +0200)
commitd3005b09a6bebb2d259441a7e8c88b98b1f0669d
treeb4079a23f466a221d26946a31748db0c3de47668
parentabae7dd2bf7af0a6dab4f04f7f8641bac15489ed
fuse: do not use iocb after it may have been freed

commit 7cabc61e01a0a8b663bd2b4c982aa53048218734 upstream.

There's a race in fuse_direct_IO(), whereby is_sync_kiocb() is called on an
iocb that could have been freed if async io has already completed.  The fix
in this case is simple and obvious: cache the result before starting io.

It was discovered by KASan:

Kernel: ==================================================================
Kernel: BUG: KASan: use after free in fuse_direct_IO+0xb1a/0xcc0 at addr ffff88036c414390

Signed-off-by: Robert Doebbelin <robert@quobyte.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Fixes: bcba24ccdc82 ("fuse: enable asynchronous processing direct IO")
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Willy Tarreau <w@1wt.eu>
fs/fuse/file.c