Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp839724rwb; Sun, 6 Nov 2022 14:53:58 -0800 (PST) X-Google-Smtp-Source: AMsMyM5RG1IgnojJvF3MZf2xx/Geocf8W2q9vbR/6PnQ9FTtzzKJJXm1bCznJlpUPCjzQTw9DqWi X-Received: by 2002:a05:6402:5299:b0:461:d052:be34 with SMTP id en25-20020a056402529900b00461d052be34mr47279888edb.42.1667775238772; Sun, 06 Nov 2022 14:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667775238; cv=none; d=google.com; s=arc-20160816; b=VBwf0lCLO5de0FXF8wOvnKA63+coZMpq0iUh+482fApMZWwS56SexO2tPeIJsuJFTa MJ/1OoK/iX/Jbid7X4XthtuTpcYk2VTzidsxkEIBei2dV+EYOp+MCbpuu0AgHXJVYO3m EYw8+e7xyhoDdBRF8xiOsuArANJ6In2eAhenTrIVcWUZwVzE5Y3puk7RfXzFdkAJVpZL dYr9JVQQsbpLNkFqJEsDTgdfFISHO05iqDh2RL3PuJYSHGdZJdlc6BBXxgQfv4ssFJtu qb7U8VurZg6hz6xVqmJd0CQWV2wtx+D6j8FOSzElcIU8DK55qMNQNjk++pnJ2e/4Ci9T Qpjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Hni8f6IBw6SwtoHy7JLtdv4RwAwM3QMwOwt+QOzkYv8=; b=pEaggxwZI+Yln17OSBQbYTMl4hx4ijSUpV0ImuQ45ZIfDpM+ChTfrSY2lAelqGamN2 tTpk8DfZLNVpDdzBFts9shpqdE49z08/yPXy5rh6fMJ4hl3FCPWkbGaQnX/9TJ30kk9s wk87HhbAWm2aSrU8iaKY2uaxjE9tCYzAQi50tcEAnPuCLCAwSFlLowtd7u5745EAsfZC iqt61kTQa4SE+J791giZmSD+36X6fZkmMmcUjGuS+JaLknNxnj6Gp1akJZcdaRNdGMvn 5BfSpIDxW9rSaUj+HyNeH2Y/e78uRz9cyjPMzA0TiYn6X5TgNdWUOMzW7Scn9xIbR5Ln QiUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WXBl6TrA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hu9-20020a170907a08900b007ad8a7a1a7asi6187847ejc.511.2022.11.06.14.53.35; Sun, 06 Nov 2022 14:53:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WXBl6TrA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbiKFWwm (ORCPT + 99 others); Sun, 6 Nov 2022 17:52:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230241AbiKFWwi (ORCPT ); Sun, 6 Nov 2022 17:52:38 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33D23101CE; Sun, 6 Nov 2022 14:52:37 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E135DB80D43; Sun, 6 Nov 2022 22:52:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D251C433B5; Sun, 6 Nov 2022 22:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667775154; bh=TjmpkjWX9P8hHhPptyAvKB3UAJOnIEmiV1SrLIr0HMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WXBl6TrAjAlnwKaZuDZAR+itCHZgqa0Z8t88t8bP6qxyjQN8U+7Oln8DStKlsjDni cZWLaB0RTByVv0z0lMYHaZM+5KkigAUkcDKsDKXNCI4RA8avBJtDXUXMKDQs6nSDM3 1G7pdclFHySOOYwPlgfaP3R/crCKOfQlFS/Yr7woaz2vyn5duEjluJFcfQfyRTQKnM v2f6PcamP/5SQH1nfJ+nj+LGz46SPc5sN9bg/c+Xs7CAPNXv3kz7TCTdZINTSydRmr 9KvAWBct0H7HjIKOHwC61XVK/uqObEELAqrrw8DDTVngw3jcq3vcn8tczcU5wxJoza Vu34DlXvgAR3w== From: Eric Biggers To: linux-ext4@vger.kernel.org Cc: linux-fscrypt@vger.kernel.org, Harshad Shirwadkar , stable@vger.kernel.org Subject: [PATCH 3/7] ext4: fix leaking uninitialized memory in fast-commit journal Date: Sun, 6 Nov 2022 14:48:37 -0800 Message-Id: <20221106224841.279231-4-ebiggers@kernel.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221106224841.279231-1-ebiggers@kernel.org> References: <20221106224841.279231-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Eric Biggers 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 --- fs/ext4/fast_commit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/ext4/fast_commit.c b/fs/ext4/fast_commit.c index da0c8228cf9c3..1e8be05542396 100644 --- a/fs/ext4/fast_commit.c +++ b/fs/ext4/fast_commit.c @@ -737,6 +737,9 @@ static u8 *ext4_fc_reserve_space(struct super_block *sb, int len, u32 *crc) *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); @@ -793,6 +796,8 @@ static int ext4_fc_write_tail(struct super_block *sb, u32 crc) 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); -- 2.38.1