Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 946db241 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Eric Biggers
Browse files

BACKPORT: dm crypt: allow unaligned bv_offset



When slub_debug is enabled kmalloc returns unaligned memory. XFS uses
this unaligned memory for its buffers (if an unaligned buffer crosses a
page, XFS frees it and allocates a full page instead - see the function
xfs_buf_allocate_memory).

dm-crypt checks if bv_offset is aligned on page size and these checks
fail with slub_debug and XFS.

Fix this bug by removing the bv_offset checks. Switch to checking if
bv_len is aligned instead of bv_offset (this check should be sufficient
to prevent overruns if a bio with too small bv_len is received).

Fixes: 8f0009a22517 ("dm crypt: optionally support larger encryption sector size")
Cc: stable@vger.kernel.org # v4.12+
Reported-by: default avatarBruno Prémont <bonbons@sysophe.eu>
Tested-by: default avatarBruno Prémont <bonbons@sysophe.eu>
Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
Reviewed-by: default avatarMilan Broz <gmazyland@gmail.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>

(cherry picked from commit 0440d5c0ca9744b92a07aeb6df0a9a75db6f4280)

Conflicts:
	drivers/md/dm-crypt.c

Change-Id: Ib8aa866d8737b2a46fefd3ea3c07de686829b715
Bug: 112008522
Test: As series, see Ie247fd41b11adcf8520de0b1554568a1b7155860
Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
parent 87e52a46
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -864,7 +864,7 @@ static int crypt_convert_block(struct crypt_config *cc,
	int r;

	/* Reject unexpected unaligned bio. */
	if (unlikely(bv_in.bv_offset & (cc->sector_size - 1)))
	if (unlikely(bv_in.bv_len & (cc->sector_size - 1)))
		return -EIO;

	dmreq = dmreq_of_req(cc, req);