summaryrefslogtreecommitdiffstats
path: root/drivers/block/loop.h
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2017-09-01 11:15:17 -0700
committerJens Axboe <axboe@kernel.dk>2017-09-01 13:57:33 -0600
commit92d773324b7edbd36bf0c28c1e0157763aeccc92 (patch)
tree333db14ef4338ba1daa5063535730c9c3ea3b0d9 /drivers/block/loop.h
parent12cd3a2fe3ba6d1a2cf007e4e8dcfbe66d3d0a28 (diff)
downloadlinux-92d773324b7edbd36bf0c28c1e0157763aeccc92.tar.bz2
block/loop: fix use after free
lo_rw_aio->call_read_iter-> 1 aops->direct_IO 2 iov_iter_revert lo_rw_aio_complete could happen between 1 and 2, the bio and bvec could be freed before 2, which accesses bvec. Signed-off-by: Shaohua Li <shli@fb.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/loop.h')
-rw-r--r--drivers/block/loop.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/block/loop.h b/drivers/block/loop.h
index 43d20d37b79a..b0ba4a5951c4 100644
--- a/drivers/block/loop.h
+++ b/drivers/block/loop.h
@@ -68,7 +68,10 @@ struct loop_cmd {
struct kthread_work work;
struct request *rq;
struct list_head list;
- bool use_aio; /* use AIO interface to handle I/O */
+ union {
+ bool use_aio; /* use AIO interface to handle I/O */
+ atomic_t ref; /* only for aio */
+ };
long ret;
struct kiocb iocb;
struct bio_vec *bvec;