dm-crypt: fully initialize clone->bi_iter in crypt_alloc_buffer()
authorHou Tao <houtao1@huawei.com>
Mon, 20 Jan 2025 08:29:47 +0000 (16:29 +0800)
committerMikulas Patocka <mpatocka@redhat.com>
Tue, 21 Jan 2025 12:25:09 +0000 (13:25 +0100)
commit7c88f7cfab553016a1b02a38ba261d9ac3750b6a
tree0b0c30ffb47db234e68050aef79ab773a862fd33
parent6fd2cb38c006cbdc4653e7e15e37ab23af59c2de
dm-crypt: fully initialize clone->bi_iter in crypt_alloc_buffer()

Both kcryptd_io_read() and kcryptd_crypt_write_convert() will invoke
crypt_alloc_buffer() to allocate a new bio. Both of these two callers
initialize bi_iter.bi_sector for the new bio separatedly after
crypt_alloc_buffer() returns. However, kcryptd_crypt_write_convert()
will copy the bi_iter of the new bio into ctx.iter_out or ctx.iter_in.
Although it doesn't incur any harm now, it is better to fully initialize
bi_iter before it is used.

Therefore, initialize bi_iter.bi_sector in crypt_alloc_buffer() instead.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-crypt.c