UBIFS: Add log overlap assertions
Subsystems (2)
PATCH 1/1 UBIFS: Add log overlap assertions
We use a circle area to record log node in ubifs. This log area should not be overlapped. But after researching the code, I found some condition may lead log head wrap log ltail. Although we've fixed the problems discovered, there may be some other issues still left.
This patch adds assertions when lhead changes to next leb to make sure ltail is not wrapped.
--- fs/ubifs/log.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ubifs/log.c +2 -0
@@ -244,6 +244,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs)if (c->lhead_offs > c->leb_size - c->ref_node_alsz) { c->lhead_lnum =ubifs_next_log_lnum (c, c->lhead_lnum); +ubifs_assert (c->lhead_lnum != c->ltail_lnum); c->lhead_offs =0 ; }
@@ -408,6 +409,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum)/* Switch to the next log LEB */ if (c->lhead_offs) { c->lhead_lnum =ubifs_next_log_lnum (c, c->lhead_lnum); +ubifs_assert (c->lhead_lnum != c->ltail_lnum); c->lhead_offs =0 ; }
Signature · 1 line
1.8.1.4
Quoted 28 lines · hujianyang
We use a circle area to record log node in ubifs. This log area should not be overlapped. But after researching the code, I found some condition may lead log head wrap log ltail. Although we've fixed the problems discovered, there may be some other issues still left.
This patch adds assertions when lhead changes to next leb to make sure ltail is not wrapped.
Signed-off-by hujianyang <[email protected]>--- fs/ubifs/log.c | 2 ++ 1 file changed, 2 insertions(+)fs/ubifs/log.c +1
-0@@ -244,6 +244,7 @@ int ubifs_add_bud_to_log(struct ubifs_info *c, int jhead, int lnum, int offs)if (c->lhead_offs > c->leb_size - c->ref_node_alsz) { c->lhead_lnum =ubifs_next_log_lnum (c, c->lhead_lnum); +ubifs_assert (c->lhead_lnum != c->ltail_lnum); c->lhead_offs =0 ; }
fs/ubifs/log.c int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum) · line 415
Quoted 7 lines
fs/ubifs/log.c +1
-0@@ -408,6 +409,7 @@ int ubifs_log_start_commit(struct ubifs_info *c, int *ltail_lnum)/* Switch to the next log LEB */ if (c->lhead_offs) { c->lhead_lnum =ubifs_next_log_lnum (c, c->lhead_lnum); +ubifs_assert (c->lhead_lnum != c->ltail_lnum); c->lhead_offs =0 ; }
Forgive me. This patch is not created in right format.
Please drop it and I will resend a new one.