Whamcloud - gitweb
LU-6995 osd: fix invalid use of bvec_iter_page 67/15967/2
authorFrank Zago <fzago@cray.com>
Wed, 12 Aug 2015 16:44:24 +0000 (11:44 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 19 Sep 2015 03:33:28 +0000 (03:33 +0000)
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 <fzago@cray.com>
Change-Id: I390b527bacae9dd650814bb19ab2dbc9184a605d
Reviewed-on: http://review.whamcloud.com/15967
Tested-by: Jenkins
Reviewed-by: Patrick Farrell <paf@cray.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre_compat.h
lustre/osd-ldiskfs/osd_io.c

index 627edf8..c038aa1 100644 (file)
@@ -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
index 7356fb2..01b574b 100644 (file)
@@ -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 {