Patch "dm-integrity: fix a memory leak when rechecking the data" has been added to the 6.8-stable tree
Sasha Levin
AppliedThis is a note to let you know that I've just added the patch titled
dm-integrity: fix a memory leak when rechecking the data
to the 6.8-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
dm-integrity-fix-a-memory-leak-when-rechecking-the-d.patch
and it can be found in the queue-6.8 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
commit ef98187329030eae6af5d8d20a8375d6c0a45877
Author: Mikulas Patocka <[email protected]> Date: Mon Mar 18 18:35:06 2024 +0100
dm-integrity: fix a memory leak when rechecking the data
[ Upstream commit 55e565c42dce81a4e49c13262d5bc4eb4c2e588a ]
Memory for the "checksums" pointer will leak if the data is rechecked after checksum failure (because the associated kfree won't happen due to 'goto skip_io').
Fix this by freeing the checksums memory before recheck, and just use the "checksum_onstack" memory for storing checksum during recheck.
drivers/md/dm-integrity.c +3 -3
@@ -1848,12 +1848,12 @@ static void integrity_metadata(struct work_struct *w) r =dm_integrity_rw_tag (ic, checksums, &dio->metadata_block, &dio->metadata_offset, checksums_ptr - checksums, dio->op ==REQ_OP_READ ?TAG_CMP :TAG_WRITE );if (unlikely (r)) { +if (likely (checksums != checksums_onstack)) +kfree (checksums);if (r >0 ) { -integrity_recheck (dio, checksums); +integrity_recheck (dio, checksums_onstack); goto skip_io; } -if (likely (checksums != checksums_onstack)) -kfree (checksums); goto error; }