]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm-integrity: don't modify bio's immutable bio_vec in integrity_metadata()
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 5 Dec 2023 15:39:16 +0000 (16:39 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 1 Jan 2024 12:39:07 +0000 (12:39 +0000)
commit7f7efa30fa87e60ae43574edf0ff1d63bd1dcee2
treedd1f94a60bd00dc8abc0316dbacd8a02a24611b5
parent33b976a0f2aeecdb4be1aafe6822593833028184
dm-integrity: don't modify bio's immutable bio_vec in integrity_metadata()

commit b86f4b790c998afdbc88fe1aa55cfe89c4068726 upstream.

__bio_for_each_segment assumes that the first struct bio_vec argument
doesn't change - it calls "bio_advance_iter_single((bio), &(iter),
(bvl).bv_len)" to advance the iterator. Unfortunately, the dm-integrity
code changes the bio_vec with "bv.bv_len -= pos". When this code path
is taken, the iterator would be out of sync and dm-integrity would
report errors. This happens if the machine is out of memory and
"kmalloc" fails.

Fix this bug by making a copy of "bv" and changing the copy instead.

Fixes: 7eada909bfd7 ("dm: add integrity target")
Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-integrity.c