Message ID | 20210604195900.2096121-11-satyat@google.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ensure bios aren't split in middle of crypto data unit | expand |
On Fri, Jun 04, 2021 at 07:59:00PM +0000, Satya Tangirala wrote: > The number of sectors passed to bio_split() should be aligned to > bio_required_sector_alignment(). should => must? - Eric
diff --git a/block/bio.c b/block/bio.c index 44205dfb6b60..32f75f31bb5c 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1436,6 +1436,7 @@ struct bio *bio_split(struct bio *bio, int sectors, BUG_ON(sectors <= 0); BUG_ON(sectors >= bio_sectors(bio)); + WARN_ON_ONCE(!IS_ALIGNED(sectors, bio_required_sector_alignment(bio))); /* Zone append commands cannot be split */ if (WARN_ON_ONCE(bio_op(bio) == REQ_OP_ZONE_APPEND))
The number of sectors passed to bio_split() should be aligned to bio_required_sector_alignment(). All callers (other than bounce.c) have been updated to ensure this, so add a WARN_ON_ONCE() if the number of sectors is not aligned. (bounce.c was not updated since it's legacy code - any device that enables bounce buffering won't declare inline encryption support, so bounce.c will never see a bio with an encryption context). Signed-off-by: Satya Tangirala <satyat@google.com> --- block/bio.c | 1 + 1 file changed, 1 insertion(+)