]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
dm crypt: allow unaligned bv_offset
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 7 Nov 2017 15:35:57 +0000 (10:35 -0500)
committerMike Snitzer <snitzer@redhat.com>
Fri, 10 Nov 2017 20:44:58 +0000 (15:44 -0500)
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: Bruno Prémont <bonbons@sysophe.eu>
Tested-by: Bruno Prémont <bonbons@sysophe.eu>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-crypt.c

index 96ab46512e1fdcf27e4669f22d97b553b491c196..9fc12f556534b71ccbb91848d4eb9dc7395bd8fa 100644 (file)
@@ -1075,7 +1075,7 @@ static int crypt_convert_block_aead(struct crypt_config *cc,
        BUG_ON(cc->integrity_iv_size && cc->integrity_iv_size != cc->iv_size);
 
        /* 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);
@@ -1168,7 +1168,7 @@ static int crypt_convert_block_skcipher(struct crypt_config *cc,
        int r = 0;
 
        /* 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);