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 315A325E82D; Tue, 11 Mar 2025 15:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741706588; cv=none; b=nV/3+8D+vv4Y2hYqO2iP2FDTaOPQR6Zg5CxeQYOLl52qEiQeK/yduB267Jnr3Cgek9L0ctuJT646fFf3xlcG79m0p+sINaivEovKLNzGphH5/k2AYCqSfYLOKifBaFlPfUz+B8Kok5KexgZA2xhoJ1ZnsBEEYfPAiEpkuhLxcYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741706588; c=relaxed/simple; bh=lVjL1EB6MWHrY9xhY6ViVO6uAJjX3HhzRfhO6FAIY1s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o7+/7SnhXSHVbmrSRXGqixTDpd4gWDfJKkvP4OflwKxWtTE/Pavq2l8Wv2RRrd68zdW+4pN1Ju+JUKha7Apt/0sKoJw07N0kzst4KwkgfGd/9oTsGvuAFD6GYfspJxZzNLEZKz+buT1cylaWTTYAH9wxLSyDAgAzFU1Q4SWAcVg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qUHt9aR+; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="qUHt9aR+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6AF9C4CEE9; Tue, 11 Mar 2025 15:23:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1741706588; bh=lVjL1EB6MWHrY9xhY6ViVO6uAJjX3HhzRfhO6FAIY1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qUHt9aR+Yvt2c+jLjEoUWqoJTpRySsOyydCdkDH+GsOoN9Z3uzLioaMT7vOC4AiQq uYtPVJgU7i8txM8Fhb2lEXkQejf+XBWpnOZPMlWMJ0e+/N/8XxB2P+1q27Z6ZY3EIk NfY6xysBOCwmb9vO548JI9INdb0VS9i9o0CilS7c= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, pangliyuan , Zhihao Cheng , Richard Weinberger , Sasha Levin Subject: [PATCH 5.10 099/462] ubifs: skip dumping tnc tree when zroot is null Date: Tue, 11 Mar 2025 15:56:05 +0100 Message-ID: <20250311145802.269078539@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250311145758.343076290@linuxfoundation.org> References: <20250311145758.343076290@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: pangliyuan [ Upstream commit bdb0ca39e0acccf6771db49c3f94ed787d05f2d7 ] Clearing slab cache will free all znode in memory and make c->zroot.znode = NULL, then dumping tnc tree will access c->zroot.znode which cause null pointer dereference. Link: https://bugzilla.kernel.org/show_bug.cgi?id=219624#c0 Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") Signed-off-by: pangliyuan Reviewed-by: Zhihao Cheng Signed-off-by: Richard Weinberger Signed-off-by: Sasha Levin --- fs/ubifs/debug.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/fs/ubifs/debug.c b/fs/ubifs/debug.c index ebff43f8009c2..9ee58cf4d53f6 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c @@ -925,16 +925,20 @@ void ubifs_dump_tnc(struct ubifs_info *c) pr_err("\n"); pr_err("(pid %d) start dumping TNC tree\n", current->pid); - znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, NULL); - level = znode->level; - pr_err("== Level %d ==\n", level); - while (znode) { - if (level != znode->level) { - level = znode->level; - pr_err("== Level %d ==\n", level); + if (c->zroot.znode) { + znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, NULL); + level = znode->level; + pr_err("== Level %d ==\n", level); + while (znode) { + if (level != znode->level) { + level = znode->level; + pr_err("== Level %d ==\n", level); + } + ubifs_dump_znode(c, znode); + znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, znode); } - ubifs_dump_znode(c, znode); - znode = ubifs_tnc_levelorder_next(c, c->zroot.znode, znode); + } else { + pr_err("empty TNC tree in memory\n"); } pr_err("(pid %d) finish dumping TNC tree\n", current->pid); } -- 2.39.5