diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2022-03-08 13:52:58 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:09:27 -0400 |
commit | 4d126dc8b30c2c1c69cbf600d604e7ceb8ca7f8d (patch) | |
tree | 3ef1a3ce01cddb8488b6883457274896bd027ce1 /fs/bcachefs/fs-io.c | |
parent | 590b91cf3fa419eefc917f4e37152af616c3ba5f (diff) | |
download | linux-stable-4d126dc8b30c2c1c69cbf600d604e7ceb8ca7f8d.tar.gz linux-stable-4d126dc8b30c2c1c69cbf600d604e7ceb8ca7f8d.tar.bz2 linux-stable-4d126dc8b30c2c1c69cbf600d604e7ceb8ca7f8d.zip |
bcachefs: Use bio_iov_vecs_to_alloc()
This fixes a bug in the DIO read path where, when using a loopback
device in DIO mode, we'd allocate a biovec that would get overwritten
and leaked in bio_iov_iter_get_pages() -> bio_iov_bvec_set().
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/fs-io.c')
-rw-r--r-- | fs/bcachefs/fs-io.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c index 9161125aec17..8231c29a7534 100644 --- a/fs/bcachefs/fs-io.c +++ b/fs/bcachefs/fs-io.c @@ -1889,7 +1889,7 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter) iter->count -= shorten; bio = bio_alloc_bioset(NULL, - iov_iter_npages(iter, BIO_MAX_VECS), + bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS), REQ_OP_READ, GFP_KERNEL, &c->dio_read_bioset); @@ -1926,7 +1926,7 @@ static int bch2_direct_IO_read(struct kiocb *req, struct iov_iter *iter) goto start; while (iter->count) { bio = bio_alloc_bioset(NULL, - iov_iter_npages(iter, BIO_MAX_VECS), + bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS), REQ_OP_READ, GFP_KERNEL, &c->bio_read); @@ -2297,9 +2297,7 @@ ssize_t bch2_direct_write(struct kiocb *req, struct iov_iter *iter) } bio = bio_alloc_bioset(NULL, - iov_iter_is_bvec(iter) - ? 0 - : iov_iter_npages(iter, BIO_MAX_VECS), + bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS), REQ_OP_WRITE, GFP_KERNEL, &c->dio_write_bioset); |