Re: block/t10-pi.c: blk_integrity_interval() prot_iter misalignment with extended metadata
Christoph Hellwig <[email protected]>
| Newsgroups | org.kernel.vger.linux-block |
|---|---|
| Message-ID | <[email protected]> |
On Wed, Aug 12, 2026 at 02:37:28PM +0200, Ricardo AlgRicSpain wrote: > Hi, > > blk_integrity_interval() (block/t10-pi.c:270-305) advances prot_iter > inconsistently: > > - fast path (t10-pi.c:282): advances metadata_size - pi_offset bytes > - split-tuple path (t10-pi.c:285-287, 296-299): advances only > pi_tuple_size bytes via blk_integrity_copy_to_tuple/copy_from_tuple > > When metadata_size - pi_offset > pi_tuple_size (e.g. NVMe extended > metadata) and the tuple splits across bvec segments, prot_iter > under-advances by the trailing opaque bytes, and the offset accumulates > across subsequent intervals, breaking guard/data correspondence on > verify and generate. > > Suggested fix: after copy_to_tuple/copy_from_tuple, advance the > remaining bytes: > > bvec_iter_advance(iter->bip->bip_vec, &iter->prot_iter, > iter->bi->metadata_size - iter->bi->pi_offset - > iter->bi->pi_tuple_size); > > ...matching what blk_tuple_remap_end() already does (t10-pi.c:426-436). > > Standalone C PoC reproducing the misalignment attached (poc.c). Please send a patch with your proposed fix. Wiring up your reproducer in blktests would also be very helpful.