Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1660257 > unrolled thread

[PATCH] ubifs: Fail commit if TNC is obviously inconsistent

Started byRichard Weinberger <richard@nod.at>
First post2017-06-07 23:40 +0200
Last post2017-06-07 23:40 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH] ubifs: Fail commit if TNC is obviously inconsistent Richard Weinberger <richard@nod.at> - 2017-06-07 23:40 +0200

#1660257 — [PATCH] ubifs: Fail commit if TNC is obviously inconsistent

FromRichard Weinberger <richard@nod.at>
Date2017-06-07 23:40 +0200
Subject[PATCH] ubifs: Fail commit if TNC is obviously inconsistent
Message-ID<tPQQh-3EL-5@gated-at.bofh.it>
A reference to LEB 0 or with length 0 in the TNC
is never correct and could be caused by a memory corruption.
Don't write such a bad index node to the MTD.
Instead fail the commit which will turn UBIFS into read-only mode.

This is less painful than having the bad reference on the MTD
from where UBFIS has no chance to recover.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 fs/ubifs/tnc_commit.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c
index 51157da3f76e..aa31f60220ef 100644
--- a/fs/ubifs/tnc_commit.c
+++ b/fs/ubifs/tnc_commit.c
@@ -57,6 +57,8 @@ static int make_idx_node(struct ubifs_info *c, struct ubifs_idx_node *idx,
 			ubifs_dump_znode(c, znode);
 			if (zbr->znode)
 				ubifs_dump_znode(c, zbr->znode);
+
+			return -EINVAL;
 		}
 	}
 	ubifs_prepare_node(c, idx, len, 0);
@@ -859,6 +861,8 @@ static int write_index(struct ubifs_info *c)
 				ubifs_dump_znode(c, znode);
 				if (zbr->znode)
 					ubifs_dump_znode(c, zbr->znode);
+
+				return -EINVAL;
 			}
 		}
 		len = ubifs_idx_node_sz(c, znode->child_cnt);
-- 
2.12.3

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web