* [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb()
@ 2018-07-04 14:02 Richard Weinberger
2023-01-06 12:18 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Richard Weinberger @ 2018-07-04 14:02 UTC (permalink / raw)
To: linux-mtd; +Cc: linux-kernel, Richard Weinberger
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb()
2018-07-04 14:02 [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb() Richard Weinberger
@ 2023-01-06 12:18 ` Sascha Hauer
2023-01-10 8:03 ` Richard Weinberger
0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2023-01-06 12:18 UTC (permalink / raw)
To: Richard Weinberger; +Cc: linux-mtd, linux-kernel
Hi Richard,
On Wed, Jul 04, 2018 at 04:02:30PM +0200, Richard Weinberger wrote:
> 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(-)
What happened to this patch? It never made it anywhere. I just stumbled
over this issue and found this patch afterwards.
>
> 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;
> + }
This changes the behaviour. With ubifs_assert() UBIFS goes readonly, but
with this change it stays rw. Is this intended?
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb()
2023-01-06 12:18 ` Sascha Hauer
@ 2023-01-10 8:03 ` Richard Weinberger
0 siblings, 0 replies; 3+ messages in thread
From: Richard Weinberger @ 2023-01-10 8:03 UTC (permalink / raw)
To: Sascha Hauer; +Cc: linux-mtd, linux-kernel
Sascha,
----- Ursprüngliche Mail -----
> What happened to this patch? It never made it anywhere. I just stumbled
> over this issue and found this patch afterwards.
I have withdrawn this patch because it cures only a symptom and not
the root cause. The root cause is a LPT corruption.
IIRC I saw the problem while investigating into another problem which
caused UBIFS corruptions.
Thanks,
//richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-10 8:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-04 14:02 [PATCH] ubifs: Handle LPT corruption better in ubifs_garbage_collect_leb() Richard Weinberger
2023-01-06 12:18 ` Sascha Hauer
2023-01-10 8:03 ` Richard Weinberger
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).