From: Richard Weinberger <richard@nod.at>
To: linux-mtd@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, Richard Weinberger <richard@nod.at>
Subject: [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb()
Date: Wed, 4 Jul 2018 16:02:30 +0200 [thread overview]
Message-ID: <20180704140230.5606-1-richard@nod.at> (raw)
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: <stable@vger.kernel.org>
Fixes: 1e51764a3c2a ("UBIFS: add new flash file system")
Signed-off-by: Richard Weinberger <richard@nod.at>
---
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) {
--
2.18.0
next reply other threads:[~2018-07-04 14:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-04 14:02 Richard Weinberger [this message]
2023-01-06 12:18 ` [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb() Sascha Hauer
2023-01-10 8:03 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180704140230.5606-1-richard@nod.at \
--to=richard@nod.at \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).