Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2210193iof; Tue, 7 Jun 2022 23:18:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZbnDqS0OyF1Jssi4nxvIR+d58hJAlrweYsZomYT95MC2QktvFO8XzEBcUXsjWrm/TwAUa X-Received: by 2002:a17:902:cecb:b0:163:fc74:b6a8 with SMTP id d11-20020a170902cecb00b00163fc74b6a8mr32028965plg.82.1654669091121; Tue, 07 Jun 2022 23:18:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654669091; cv=none; d=google.com; s=arc-20160816; b=haMb5oMea4ZwS+1jFGV2N4le0QGQXO1jRw9sIvmvJ7YmlDsmzZrB0sakxVdxeoK3ni JN0IygHCQYyntUvwlAFKu3JVtpDq83c6CNajmC9NUMQSbcrp3q1WoMRFkLQ2CyBUjk4f 5OTVN7S7MFyBBWqg4soKJ5Ytdnis29cv5DySNbXs7XcfEAi16ExIgjiougCeyIXM82nk 1dYwFVAjH3t2NHfARN8rnMnyDD7RTmYnGJ0swZPKqTbOIS8kXaxeFjfjmhmodAALYob9 nCl2Sxe6NuuJBw+uiUS7sxgJ5VaYP6s+fvRgMsxbejwrZf6fCIwsNtIo75tfrf0TGdHP SrRA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/rsfthm/zR2zec7oIma9IAU+SfMLAf7mh8GFNkZSBOk=; b=MGf5R/TK6ycp+9qSE8HJkgqyNhpKWDgcuIsnHTYqL0OS3C4np0choIbJMORqHcwoLc RwQi2E5cLoo//Z9RfKlv0ossmjdJzOo/bKn2w1Ydy3O/Ty+NbdJtKsHAigs/I30IJZ9M 173JVAQoWk6kP/Sz5Is4eV/BV2MUk+R+WgpQzdl56YYxTL5mgk05vG4fF/L1TYIZkq1t zFAtc7acpCgNnHRfuBFsAW3xDHP2Z3bPZZk7UIhWxfbgZLPf5w+ZbHHKcth/IVqhmSSE /L9+ADoZMldc2cjLZNtI/y3gx23brL2iqkUqH17GJydxwdQhi1QdOaqYmVrx+rWZPecv vfBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=twn5HbOg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id ix15-20020a170902f80f00b001638d6105cesi24895849plb.495.2022.06.07.23.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:18:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=twn5HbOg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8848137B7EF; Tue, 7 Jun 2022 22:39:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350648AbiFHB4T (ORCPT + 99 others); Tue, 7 Jun 2022 21:56:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1588057AbiFGXyE (ORCPT ); Tue, 7 Jun 2022 19:54:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D1E024585; Tue, 7 Jun 2022 12:25:47 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id A6D69609D0; Tue, 7 Jun 2022 19:25:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5119C385A2; Tue, 7 Jun 2022 19:25:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629946; bh=i2aBAC+nkmqctlRSusmxse0DlTK5H314CzgX7Q94to0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=twn5HbOgRJlHMjdCq/w7NgQIS503LaFWIo0/9cXWN4kCz+El4Jo06DpqrAhc81bbk 16SXKcyp+1J7fNXKDJrElp7blaLGg2zWxxaW4tRQt+rE0o8SvhL397fCNkYlbliPpV Uq5y5R+p5B+7XqIqh8c4Bs9HS9mTAUnqBDz05gRI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerald Lee , Namjae Jeon , Konstantin Komarov Subject: [PATCH 5.18 874/879] fs/ntfs3: Fix invalid free in log_replay Date: Tue, 7 Jun 2022 19:06:32 +0200 Message-Id: <20220607165028.226911354@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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-kernel@vger.kernel.org From: Namjae Jeon commit f26967b9f7a830e228bb13fb41bd516ddd9d789d upstream. log_read_rst() returns ENOMEM error when there is not enough memory. In this case, if info is returned without initialization, it attempts to kfree the uninitialized info->r_page pointer. This patch moves the memset initialization code to before log_read_rst() is called. Reported-by: Gerald Lee Signed-off-by: Namjae Jeon Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- fs/ntfs3/fslog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/fs/ntfs3/fslog.c +++ b/fs/ntfs3/fslog.c @@ -1185,8 +1185,6 @@ static int log_read_rst(struct ntfs_log if (!r_page) return -ENOMEM; - memset(info, 0, sizeof(struct restart_info)); - /* Determine which restart area we are looking for. */ if (first) { vbo = 0; @@ -3791,10 +3789,11 @@ int log_replay(struct ntfs_inode *ni, bo if (!log) return -ENOMEM; + memset(&rst_info, 0, sizeof(struct restart_info)); + log->ni = ni; log->l_size = l_size; log->one_page_buf = kmalloc(page_size, GFP_NOFS); - if (!log->one_page_buf) { err = -ENOMEM; goto out; @@ -3842,6 +3841,7 @@ int log_replay(struct ntfs_inode *ni, bo if (rst_info.vbo) goto check_restart_area; + memset(&rst_info2, 0, sizeof(struct restart_info)); err = log_read_rst(log, l_size, false, &rst_info2); /* Determine which restart area to use. */