From decbd1c0bfbc2d6c9e43c6fb880d7cbfe41b9143 Mon Sep 17 00:00:00 2001 From: Frank Zago Date: Wed, 12 Aug 2015 11:44:24 -0500 Subject: [PATCH] LU-6995 osd: fix invalid use of bvec_iter_page bvec_iter_page is expecting a biovecs list as a first argument, not a biovec. That works as long as there is only one biovec in the bio. If there is more than one, then invalid memory is dereferences since bvl is a single vector, not a list. This only affect 3.14+ kernels, where HAVE_BVEC_ITER is true. Don't use bvec_iter_page, but create the right macro to simply return the vector's bv_page. Bug introduced in commit 833b670a. Signed-off-by: frank zago Change-Id: I390b527bacae9dd650814bb19ab2dbc9184a605d Reviewed-on: http://review.whamcloud.com/15967 Tested-by: Jenkins Reviewed-by: Patrick Farrell Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Oleg Drokin --- lustre/include/lustre_compat.h | 3 ++- lustre/osd-ldiskfs/osd_io.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 627edf8..c038aa1 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -184,6 +184,7 @@ unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm) #ifdef HAVE_BVEC_ITER #define bio_idx(bio) (bio->bi_iter.bi_idx) #define bio_set_sector(bio, sector) (bio->bi_iter.bi_sector = sector) +#define bvl_to_page(bvl) (bvl.bv_page) #else #define bio_idx(bio) (bio->bi_idx) #define bio_set_sector(bio, sector) (bio->bi_sector = sector) @@ -191,7 +192,7 @@ unsigned int ll_crypto_tfm_alg_min_keysize(struct crypto_blkcipher *tfm) #ifndef HAVE_BIO_END_SECTOR #define bio_end_sector(bio) (bio->bi_sector + bio_sectors(bio)) #endif -#define bvec_iter_page(bvec, iter) (*bvec->bv_page) +#define bvl_to_page(bvl) (bvl->bv_page) #endif #ifndef HAVE_BLK_QUEUE_MAX_SEGMENTS diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 7356fb2..01b574b 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -181,8 +181,8 @@ static void dio_complete_routine(struct bio *bio, int error) if (!test_bit(__REQ_WRITE, &bio->bi_rw)) { bio_for_each_segment(bvl, bio, iter) { if (likely(error == 0)) - SetPageUptodate(bvec_iter_page(&bvl, iter)); - LASSERT(PageLocked(bvec_iter_page(&bvl, iter))); + SetPageUptodate(bvl_to_page(bvl)); + LASSERT(PageLocked(bvl_to_page(bvl))); } atomic_dec(&iobuf->dr_dev->od_r_in_flight); } else { -- 1.8.3.1