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 43FEC1DB546; Wed, 19 Feb 2025 09:17:14 +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=1739956634; cv=none; b=H0fGlowZaQlm6UJk/lQjHDiZhXS0ohzM6mwhpDknrytIcWb7teau4Sp8XCp5eag0fwXlsUFfGkz1QsH06xPRiNqQB5SrgcrKzBO+fWkEvKRXDYJyUV3pCz/N88crqpj2I6pfquP6eTBndumI18BnZx+GMH8W9TQ7po3lWzYk40U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739956634; c=relaxed/simple; bh=3SSh+Q2t+ONVATC58OdkvXT6h6Cdb46ixc6nmM546r0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LjNnEEgEbnLLugw05PlafhvD1QvstuefhBDQ9mJU3mqn0HCyuM9b+/kLDmI5rPfEL6E/JpTKJNcwIc9F7SCntHQzRkPrGYzQ2gV4VMMDWmBVZNzsghQzAUQptMnIndRvKbRruMzmDIZ1K8pk+owxlGkOuesyxmLv+gmAI8QgoSk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tLy9MCBF; 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="tLy9MCBF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1850C4CED1; Wed, 19 Feb 2025 09:17:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739956634; bh=3SSh+Q2t+ONVATC58OdkvXT6h6Cdb46ixc6nmM546r0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tLy9MCBFjHHC0hXbRIBNzjURflKbTSrNz896aRpOOU3y+UMaMRiio6ytLEDI5LOYo +jK2wrN0+98FfTCXT4vttpc576jLD8/S6e4WZDP6rtdnk332EP4x+RCMFuTL3iDGJE b+TgK5Q2fX5Qk3AinpUiU501y3bvqli0maDW4eto= 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 6.1 215/578] ubifs: skip dumping tnc tree when zroot is null Date: Wed, 19 Feb 2025 09:23:39 +0100 Message-ID: <20250219082701.514391324@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250219082652.891560343@linuxfoundation.org> References: <20250219082652.891560343@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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 3f128b9fdfbb2..9613725ed1935 100644 --- a/fs/ubifs/debug.c +++ b/fs/ubifs/debug.c @@ -946,16 +946,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