Re: dm-crypt: Fix error with too large bios
From: Mikulas Patocka <mpatocka@redhat.com>
Date: 2016-08-30 12:19:46
Also in:
dm-devel
On Tue, 30 Aug 2016, Ming Lei wrote:
On Tue, Aug 30, 2016 at 5:57 AM, Mikulas Patocka [off-list ref] wrote:quoted
On Mon, 29 Aug 2016, Ming Lei wrote:quoted
On Sat, Aug 27, 2016 at 11:09 PM, Mikulas Patocka [off-list ref] wrote:quoted
But this patch won't work for device mapper, blk_bio_segment_split is called from blk_queue_split and device mapper doesn't use blk_queue_split (it can't because it frees queue->bio_split). We still need these two patches: https://www.redhat.com/archives/dm-devel/2016-May/msg00211.html https://www.redhat.com/archives/dm-devel/2016-May/msg00210.htmlAbout the 2nd patch, it might not be good enough because in theory a small size bio still may include big bvecs, such as, each bvec points to 512byte buffer, so strictly speaking the bvec number should be checked instead of bio size. Ming LeiThis is not a problem.I meant the following code in your 2nd patch: + if (unlikely(bio->bi_iter.bi_size > BIO_MAX_SIZE) && + (bio->bi_rw & (REQ_FLUSH | REQ_DISCARD | REQ_WRITE)) == REQ_WRITE) + dm_accept_partial_bio(bio, BIO_MAX_SIZE >> SECTOR_SHIFT); And the check on .bi_size may not work.
kcryptd_crypt_write_convert calls: crypt_alloc_buffer(io, io->base_bio->bi_iter.bi_size) crypt_alloc_buffer does: unsigned int nr_iovecs = (size + PAGE_SIZE - 1) >> PAGE_SHIFT; clone = bio_alloc_bioset(GFP_NOIO, nr_iovecs, cc->bs); So, if io->base_bio->bi_iter.bi_size <= BIO_MAX_SIZE, then nr_iovecs will be less or equal than BIO_MAX_PAGES and the function bio_alloc_bioset will succeed. (BTW. BIO_MAX_SIZE was removed in the current kernel, we should use (BIO_MAX_PAGES << PAGE_SHIFT) instead). Mikulas