6 Star 5 Fork 56

OpenHarmony/third_party_e2fsprogs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
0019-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
wangmingxuan 提交于 2024-01-03 11:33 . e2fsprogs升级
From 66ecb6abe5d2c74191bb4bc24f3da036e5fa1213 Mon Sep 17 00:00:00 2001
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Date: Mon, 5 Sep 2022 19:16:03 +0800
Subject: [PATCH] tune2fs: fix tune2fs segfault when ext2fs_run_ext3_journal()
fails
When ext2fs_run_ext3_journal() fails, tune2fs cmd will occur one
segfault problem as follows.
(gdb) bt
#0 0x00007fdadad69917 in ext2fs_mmp_stop (fs=0x0) at mmp.c:405
#1 0x0000558fa5a9365a in main (argc=<optimized out>, argv=<optimized out>) at tune2fs.c:3440
misc/tune2fs.c:
main()
-> ext2fs_open2(&fs)
-> ext2fs_mmp_start
......
-> retval = ext2fs_run_ext3_journal(&fs)
-> if (retval)
// if ext2fs_run_ext3_journal fails, close and free fs.
-> ext2fs_close_free(&fs)
-> rc = 1
-> goto closefs
......
closefs:
-> if (rc)
-> ext2fs_mmp_stop(fs) // fs has been set to NULL, boom!!
-> (ext2fs_close_free(&fs) ? 1 : 0); // close and free fs
In main() of tune2fs cmd, if ext2fs_run_ext3_journal() fails,
we should set rc=1 and goto closefs tag, in which will release fs
resource.
Fix: a2292f8a5108 ("tune2fs: reset MMP state on error exit")
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
---
misc/tune2fs.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index a7ff16de..98e38983 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -3106,8 +3106,6 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
com_err("tune2fs", retval,
"while recovering journal.\n");
printf(_("Please run e2fsck -fy %s.\n"), argv[1]);
- if (fs)
- ext2fs_close_free(&fs);
rc = 1;
goto closefs;
}
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openharmony/third_party_e2fsprogs.git
git@gitee.com:openharmony/third_party_e2fsprogs.git
openharmony
third_party_e2fsprogs
third_party_e2fsprogs
master

搜索帮助