From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F772AD48 for ; Wed, 4 Jan 2023 16:27:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F17B8C433D2; Wed, 4 Jan 2023 16:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1672849623; bh=OfMgNU9HOVTNL9A+i8r3ITOYwJJKCwChbeZVBMZJt+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F923qPPCQO7BhZLX5VELG+ERyhrjWzwZEEW3XisT1vQ40JGONrmmBkp6k7ru1Eosc KVPJ7vxJ2MzKr9O9zYG2AvujlMFTbqIdar46swibf/o4ong5G7hKMH3z18x4oT1MdY BSfyk6M3TUOJavkL0geobQ7XugVtLWNd5Zg5//0s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Biggers , Theodore Tso Subject: [PATCH 6.0 147/177] ext4: fix leaking uninitialized memory in fast-commit journal Date: Wed, 4 Jan 2023 17:07:18 +0100 Message-Id: <20230104160512.113744253@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230104160507.635888536@linuxfoundation.org> References: <20230104160507.635888536@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Eric Biggers commit 594bc43b410316d70bb42aeff168837888d96810 upstream. 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: # v5.10+ Signed-off-by: Eric Biggers Link: https://lore.kernel.org/r/20221106224841.279231-4-ebiggers@kernel.org Signed-off-by: Theodore Ts'o Signed-off-by: Greg Kroah-Hartman --- fs/ext4/fast_commit.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -745,6 +745,9 @@ static u8 *ext4_fc_reserve_space(struct *crc = ext4_chksum(sbi, *crc, tl, EXT4_FC_TAG_BASE_LEN); if (pad_len > 0) ext4_fc_memzero(sb, tl + 1, pad_len, crc); + /* Don't leak uninitialized memory in the unused last byte. */ + *((u8 *)(tl + 1) + pad_len) = 0; + ext4_fc_submit_bh(sb, false); ret = jbd2_fc_get_buf(EXT4_SB(sb)->s_journal, &bh); @@ -801,6 +804,8 @@ static int ext4_fc_write_tail(struct sup dst += sizeof(tail.fc_tid); tail.fc_crc = cpu_to_le32(crc); ext4_fc_memcpy(sb, dst, &tail.fc_crc, sizeof(tail.fc_crc), NULL); + dst += sizeof(tail.fc_crc); + memset(dst, 0, bsize - off); /* Don't leak uninitialized memory. */ ext4_fc_submit_bh(sb, true);