From patchwork Wed Jul 4 14:02:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 939366 X-Patchwork-Delegate: richard@nod.at Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nod.at Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="T8QrQMdH"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41LN4B2S0lz9s1b for ; Thu, 5 Jul 2018 00:03:06 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=9dRA+3r19p8xfHPUjDGWnLlBZLwG7cyUUHkGTwrRLgI=; b=T8Q rQMdHOLowqRias4waoBBl7mZ9VnAomTxJL/HqFfX/PtTF+sGmniY3d+hCD60NMkOpv0gF0p4aexcB jety5O1jQw8ClU6BzHZ0HVEthgjDmnnTbN1M4f7OsJeoQWdDDBcXz/ypBrGyYIAmGIMDylrNeIbzu 4XoHC5Cv5kqddUdVCkdpVgo9u+A1WEGm6z7/6dxdIWAA4cBb/fXffjJ7fspiHwHf7hZmKxrEEcGRc bwHheem6W7yGIa3essTFLuY0NvEuva6O5pCe/u9/OFaYJ1ilqaZLwsRTtMU/i4+vh8xu6nmxqTuNM 4qYbrzwb2zYoWmREty+Dg5ak5g/PArg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1faiMw-00023r-4F; Wed, 04 Jul 2018 14:02:54 +0000 Received: from lilium.sigma-star.at ([109.75.188.150]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1faiMs-00022I-O3 for linux-mtd@lists.infradead.org; Wed, 04 Jul 2018 14:02:52 +0000 Received: from localhost (localhost [127.0.0.1]) by lilium.sigma-star.at (Postfix) with ESMTP id 3F58F18186370; Wed, 4 Jul 2018 16:02:37 +0200 (CEST) From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb() Date: Wed, 4 Jul 2018 16:02:30 +0200 Message-Id: <20180704140230.5606-1-richard@nod.at> X-Mailer: git-send-email 2.18.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180704_070251_019428_5E2D14F8 X-CRM114-Status: GOOD ( 13.08 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 T_SPF_PERMERROR SPF: test of record failed (permerror) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Weinberger , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org If ubifs_garbage_collect_leb() notes a LPT problem, empty LEB, but LPT has it makred as used, an ubifs_assert() is not enough. We have to abort GC. Otherwise list_entry() returns an invalid scan object and the kernel crashes. c: Fixes: 1e51764a3c2a ("UBIFS: add new flash file system") Signed-off-by: Richard Weinberger --- fs/ubifs/gc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c index a03a47cf880d..11c09ce3c795 100644 --- a/fs/ubifs/gc.c +++ b/fs/ubifs/gc.c @@ -513,7 +513,13 @@ int ubifs_garbage_collect_leb(struct ubifs_info *c, struct ubifs_lprops *lp) if (IS_ERR(sleb)) return PTR_ERR(sleb); - ubifs_assert(!list_empty(&sleb->nodes)); + if (list_empty(&sleb->nodes)) { + ubifs_err(c, "Bad accouting information, LEB %i is marked as used but no nodes found!", + lnum); + dump_stack(); + return -EUCLEAN; + } + snod = list_entry(sleb->nodes.next, struct ubifs_scan_node, list); if (snod->type == UBIFS_IDX_NODE) {