tune2fs: fix one segfault problem
fix issue: https://gitee.com/src-openeuler/e2fsprogs/issues/I5RYHG Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
This commit is contained in:
parent
9e815d133d
commit
dbf564ce02
@ -0,0 +1,57 @@
|
||||
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
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
From 77ac16dfba42e0d152b1e99359e01a933f8cc6f9 Mon Sep 17 00:00:00 2001
|
||||
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||
Date: Mon, 5 Sep 2022 23:40:01 +0800
|
||||
Subject: [PATCH] tune2fs: tune2fs_main() should return rc when some error,
|
||||
occurs
|
||||
|
||||
If some error occurs, tune2fs_main() will go to closefs tag for
|
||||
releasing resource, and it should return correct value (rc) instead
|
||||
of 0 when ext2fs_close_free(&fs) successes.
|
||||
|
||||
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
|
||||
Reviewed-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
|
||||
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||
---
|
||||
misc/tune2fs.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
|
||||
index 98e38983..bed3d95b 100644
|
||||
--- a/misc/tune2fs.c
|
||||
+++ b/misc/tune2fs.c
|
||||
@@ -3243,6 +3243,7 @@ _("Warning: The journal is dirty. You may wish to replay the journal like:\n\n"
|
||||
fputs(_("Error in using clear_mmp. "
|
||||
"It must be used with -f\n"),
|
||||
stderr);
|
||||
+ rc = 1;
|
||||
goto closefs;
|
||||
}
|
||||
}
|
||||
@@ -3447,5 +3448,5 @@ closefs:
|
||||
|
||||
if (feature_64bit)
|
||||
convert_64bit(fs, feature_64bit);
|
||||
- return (ext2fs_close_free(&fs) ? 1 : 0);
|
||||
+ return (ext2fs_close_free(&fs) ? 1 : rc);
|
||||
}
|
||||
--
|
||||
2.33.0
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
From 3d967e53033c85ad5d3af1a42efb2c4f7501c356 Mon Sep 17 00:00:00 2001
|
||||
From: lijinlin3@huawei.com
|
||||
Date: Fri, 16 Sep 2022 18:15:02 +0200
|
||||
Subject: [PATCH] tune2fs: exit directly when fs freed in ext2fs_run_ext3_journal
|
||||
|
||||
In ext2fs_run_ext3_journal(), fs will be free and reallocate. But
|
||||
reallocating by ext2fs_open() may fail in some cases, such as device
|
||||
being offline at the same time. In these cases, goto closefs will
|
||||
cause segfault, fix it by exiting directly.
|
||||
|
||||
Signed-off-by: Li Jinlin <lijinlin3@huawei.com>
|
||||
---
|
||||
misc/tune2fs.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
|
||||
index 088f87e5..ee57dc7c 100644
|
||||
--- a/misc/tune2fs.c
|
||||
+++ b/misc/tune2fs.c
|
||||
@@ -3344,8 +3344,11 @@ _("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]);
|
||||
- rc = 1;
|
||||
- goto closefs;
|
||||
+ if (fs) {
|
||||
+ rc = 1;
|
||||
+ goto closefs;
|
||||
+ }
|
||||
+ exit(1);
|
||||
}
|
||||
sb = fs->super;
|
||||
}
|
||||
--
|
||||
2.23.0
|
||||
@ -1,6 +1,6 @@
|
||||
Name: e2fsprogs
|
||||
Version: 1.45.6
|
||||
Release: 13
|
||||
Release: 14
|
||||
Summary: Second extended file system management tools
|
||||
License: GPLv2 and LGPLv2 and GPLv2+
|
||||
URL: http://e2fsprogs.sourceforge.net/
|
||||
@ -50,8 +50,11 @@ Patch40: 0040-e2fsck-add-env-param-E2FS_UNRELIABLE_IO-to-fi.patch
|
||||
Patch41: 0041-e2fsck-do-not-clean-up-file-acl-if-the-inode-is-trun.patch
|
||||
Patch42: 0042-e2fsck-handle-level-is-overflow-in-ext2fs_extent_get.patch
|
||||
Patch43: 0043-libext2fs-add-sanity-check-to-extent-manipulation.patch
|
||||
Patch44: 0044-tune2fs-do-not-change-j_tail_sequence-in-journal-sup.patch
|
||||
Patch45: 0045-debugfs-teach-logdump-the-n-num_trans-option.patch
|
||||
Patch44: 0044-tune2fs-do-not-change-j_tail_sequence-in-journal-sup.patch
|
||||
Patch45: 0045-debugfs-teach-logdump-the-n-num_trans-option.patch
|
||||
Patch46: 0046-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch
|
||||
Patch47: 0047-tune2fs-tune2fs_main-should-return-rc-when-some-erro.patch
|
||||
Patch48: 0048-tune2fs-exit-directly-when-fs-freed-in-ext2fs_run_ext3_journal.patch
|
||||
|
||||
BuildRequires: gcc pkgconfig texinfo
|
||||
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
||||
@ -173,6 +176,9 @@ exit 0
|
||||
%{_mandir}/man8/*
|
||||
|
||||
%changelog
|
||||
* Fri Oct 14 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 1.45.6-14
|
||||
- tune2fs: fix one segfault problem
|
||||
|
||||
* Sat Aug 27 2022 yanxiaodan <yanxiaodan@huawei.com> - 1.45.6-13
|
||||
- debugfs: teach logdump the -n <num_trans> option
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user