Skip to contentSkip to conversation

block: pass correct prot_buf pointer to integrity metadata processing function

PATCH In review Sam Bradshaw 2 participants 2 messages Jan 14, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: pass correct prot_buf pointer to integrity metadata processing function

The prot_buf pointer passed to the generate/verify functions is incorrect for the second and subsequent range, making it impossible to verify the guard tag. The patch correctly increments the prot_buf pointer by the tuple size for each pass.

---

block/bio-integrity.c +2 -1
index 5cbd5d9..c7cbf60 100644
@@ -226,13 +226,13 @@ static int bio_integrity_process(struct bio *bio,
 	iter.disk_name = bio->bi_bdev->bd_disk->disk_name;
 	iter.interval = bi->interval;
 	iter.seed = bip_get_seed(bip);
-	iter.prot_buf = prot_buf;
 
 	bio_for_each_segment(bv, bio, bviter) {
 		void *kaddr = kmap_atomic(bv.bv_page);
 
 		iter.data_buf = kaddr + bv.bv_offset;
 		iter.data_size = bv.bv_len;
+		iter.prot_buf = prot_buf;
 
 		ret = proc_fn(&iter);
 		if (ret) {
@@ -241,6 +241,7 @@ static int bio_integrity_process(struct bio *bio,
 		}
 
 		kunmap_atomic(kaddr);
+		prot_buf += bi->tuple_size;
 	}
 	return ret;
 }
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Sam" == Sam Bradshaw <[email protected]> writes:

Hey Sam,

Sam> The prot_buf pointer passed to the generate/verify functions is Sam> incorrect for the second and subsequent range, making it impossible Sam> to verify the guard tag. The patch correctly increments the Sam> prot_buf pointer by the tuple size for each pass.

prot_buf is just a temporary variable used to get the kernel address of the buffer pointer. We only care about iter.prot_buf and that gets incremented by the generate or verify functions.

Are your data buffers page aligned? Things are going to break if they aren't...

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering