From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDC99C7EE23 for ; Tue, 9 May 2023 21:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236113AbjEIVWV (ORCPT ); Tue, 9 May 2023 17:22:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236019AbjEIVVd (ORCPT ); Tue, 9 May 2023 17:21:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD83C6184; Tue, 9 May 2023 14:20:27 -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 B461E634F7; Tue, 9 May 2023 21:20:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D42B0C433A8; Tue, 9 May 2023 21:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683667207; bh=vOnm0VFDx6huUZMeiw26JbXYZTo0TG8euLcvo1YuJZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iODz1hbwiOL5Tr0WK2lLabpKW0UwSPUY7L4B0OVNMC4bJwzvszybq3Y4yH2ROa724 6sJwtmjdd+0AiWxxMWMjWUwjMJzqYCVMRZW1J65He4FsnEK00h6G2LZc0rd8Bw8cqc m/4Xpxyyy5Pt3C/pPTXQ3D/pPlk7a3P+uov0tuBpvC2FdD9a/0VEUPQUlXM+yRHxm4 8bpfXQFBPXvHvR/bQ2hPDpeM+sJqAgxIhzpg4V4QK3RV00DkEX0+7aca2RMKOQjGVQ 0C/Lz5IaedWOQ87CDNI6VdCKZJ+BFqbBzOjjnKMW3a5e1CGN244+qYxSEVAQHII16W 4EIALWTdHwxhQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jia-Ju Bai , TOTE Robot , Konstantin Komarov , Sasha Levin , ntfs3@lists.linux.dev Subject: [PATCH AUTOSEL 6.2 09/18] fs/ntfs3: Fix a possible null-pointer dereference in ni_clear() Date: Tue, 9 May 2023 17:19:47 -0400 Message-Id: <20230509211958.21596-9-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230509211958.21596-1-sashal@kernel.org> References: <20230509211958.21596-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jia-Ju Bai [ Upstream commit ec275bf9693d19cc0fdce8436f4c425ced86f6e7 ] In a previous commit c1006bd13146, ni->mi.mrec in ni_write_inode() could be NULL, and thus a NULL check is added for this variable. However, in the same call stack, ni->mi.mrec can be also dereferenced in ni_clear(): ntfs_evict_inode(inode) ni_write_inode(inode, ...) ni = ntfs_i(inode); is_rec_inuse(ni->mi.mrec) -> Add a NULL check by previous commit ni_clear(ntfs_i(inode)) is_rec_inuse(ni->mi.mrec) -> No check Thus, a possible null-pointer dereference may exist in ni_clear(). To fix it, a NULL check is added in this function. Signed-off-by: Jia-Ju Bai Reported-by: TOTE Robot Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/frecord.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 912eeb3d34717..9f3c4f6a2a343 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -102,7 +102,7 @@ void ni_clear(struct ntfs_inode *ni) { struct rb_node *node; - if (!ni->vfs_inode.i_nlink && is_rec_inuse(ni->mi.mrec)) + if (!ni->vfs_inode.i_nlink && ni->mi.mrec && is_rec_inuse(ni->mi.mrec)) ni_delete_all(ni); al_destroy(ni); -- 2.39.2