Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: fix leaking uninitialized memory in fast-commit journal

When space at the end of fast-commit journal blocks is unused, make sure
to zero it out so that uninitialized memory is not leaked to disk.

Fixes: aa75f4d3daae ("ext4: main fast-commit commit path")
Cc: <stable@vger.kernel.org> # v5.10+
Signed-off-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20221106224841.279231-4-ebiggers@kernel.org
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Eric Biggers and committed by
Theodore Ts'o
594bc43b 4c0d5778

+5
+5
fs/ext4/fast_commit.c
··· 737 737 *crc = ext4_chksum(sbi, *crc, tl, EXT4_FC_TAG_BASE_LEN); 738 738 if (pad_len > 0) 739 739 ext4_fc_memzero(sb, tl + 1, pad_len, crc); 740 + /* Don't leak uninitialized memory in the unused last byte. */ 741 + *((u8 *)(tl + 1) + pad_len) = 0; 742 + 740 743 ext4_fc_submit_bh(sb, false); 741 744 742 745 ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh); ··· 796 793 dst += sizeof(tail.fc_tid); 797 794 tail.fc_crc = cpu_to_le32(crc); 798 795 ext4_fc_memcpy(sb, dst, &tail.fc_crc, sizeof(tail.fc_crc), NULL); 796 + dst += sizeof(tail.fc_crc); 797 + memset(dst, 0, bsize - off); /* Don't leak uninitialized memory. */ 799 798 800 799 ext4_fc_submit_bh(sb, true); 801 800