linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] UBIFS: Add log overlap assertions
@ 2014-07-29 10:20 hujianyang
  2014-07-30  1:32 ` hujianyang
  0 siblings, 1 reply; 2+ messages in thread
From: hujianyang @ 2014-07-29 10:20 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: linux-mtd

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 <hujianyang@huawei.com>
---
 fs/ubifs/log.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c
index 7e818ec..c14628f 100644
--- a/fs/ubifs/log.c
+++ b/fs/ubifs/log.c
@@ -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;
        }

-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] UBIFS: Add log overlap assertions
  2014-07-29 10:20 [PATCH] UBIFS: Add log overlap assertions hujianyang
@ 2014-07-30  1:32 ` hujianyang
  0 siblings, 0 replies; 2+ messages in thread
From: hujianyang @ 2014-07-30  1:32 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: linux-mtd

On 2014/7/29 18:20, hujianyang wrote:
> 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 <hujianyang@huawei.com>
> ---
>  fs/ubifs/log.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/ubifs/log.c b/fs/ubifs/log.c
> index 7e818ec..c14628f 100644
> --- a/fs/ubifs/log.c
> +++ b/fs/ubifs/log.c
> @@ -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;
>         }
> 

Forgive me. This patch is not created in right format.

Please drop it and I will resend a new one.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-30  1:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-29 10:20 [PATCH] UBIFS: Add log overlap assertions hujianyang
2014-07-30  1:32 ` hujianyang

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).