]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitac466492671a3a55552c5148f60d110bd4d08bfa
treeaedd27d5797516e04afecd33f0d224201042ea2b
parent35487b196c05ea6f76857a8685643ae95b5abb76
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: 03cac145aebc ("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