Skip to content

Commit df71b09

Browse files
ubifs: Fail commit if TNC is obviously inconsistent
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>
1 parent 319c104 commit df71b09

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎fs/ubifs/tnc_commit.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ static int make_idx_node(struct ubifs_info *c, struct ubifs_idx_node *idx,
5757
ubifs_dump_znode(c, znode);
5858
if (zbr->znode)
5959
ubifs_dump_znode(c, zbr->znode);
60+
61+
return -EINVAL;
6062
}
6163
}
6264
ubifs_prepare_node(c, idx, len, 0);
@@ -859,6 +861,8 @@ static int write_index(struct ubifs_info *c)
859861
ubifs_dump_znode(c, znode);
860862
if (zbr->znode)
861863
ubifs_dump_znode(c, zbr->znode);
864+
865+
return -EINVAL;
862866
}
863867
}
864868
len = ubifs_idx_node_sz(c, znode->child_cnt);

0 commit comments

Comments
 (0)