[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211115013144.2479319-3-libaokun1@huawei.com>
Date: Mon, 15 Nov 2021 09:31:43 +0800
From: Baokun Li <libaokun1@...wei.com>
To: <richard@....at>, <linux-mtd@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>
CC: <libaokun1@...wei.com>, <yukuai3@...wei.com>,
Hulk Robot <hulkci@...wei.com>
Subject: [PATCH -next 2/3] ubifs: fix double return leb in ubifs_garbage_collect
If ubifs_garbage_collect_leb() returns -EAGAIN and enters the "out"
branch, ubifs_return_leb will execute twice on the same lnum. This
can cause data loss in concurrency situations.
Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Baokun Li <libaokun1@...wei.com>
---
fs/ubifs/gc.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/ubifs/gc.c b/fs/ubifs/gc.c
index 05e1eeae8457..1f74a127fe3a 100644
--- a/fs/ubifs/gc.c
+++ b/fs/ubifs/gc.c
@@ -758,6 +758,8 @@ int ubifs_garbage_collect(struct ubifs_info *c, int anyway)
err = ubifs_return_leb(c, lp.lnum);
if (err)
ret = err;
+ /* Maybe double return LEB if goto out */
+ lp.lnum = -1;
break;
}
goto out;
--
2.31.1
Powered by blists - more mailing lists