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
7562b78937
commit
a90d365e90
@ -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
|
Name: e2fsprogs
|
||||||
Version: 1.46.4
|
Version: 1.46.4
|
||||||
Release: 15
|
Release: 16
|
||||||
Summary: Second extended file system management tools
|
Summary: Second extended file system management tools
|
||||||
License: GPLv2+ and LGPLv2 and MIT
|
License: GPLv2+ and LGPLv2 and MIT
|
||||||
URL: http://e2fsprogs.sourceforge.net/
|
URL: http://e2fsprogs.sourceforge.net/
|
||||||
@ -25,6 +25,9 @@ Patch15: 0015-libext2fs-add-sanity-check-to-extent-manipulation.patch
|
|||||||
Patch16: 0016-e2fsprogs-add-sw64.patch
|
Patch16: 0016-e2fsprogs-add-sw64.patch
|
||||||
Patch17: 0017-tune2fs-do-not-change-j_tail_sequence-in-journal-sup.patch
|
Patch17: 0017-tune2fs-do-not-change-j_tail_sequence-in-journal-sup.patch
|
||||||
Patch18: 0018-debugfs-teach-logdump-the-n-num_trans-option.patch
|
Patch18: 0018-debugfs-teach-logdump-the-n-num_trans-option.patch
|
||||||
|
Patch19: 0019-tune2fs-fix-tune2fs-segfault-when-ext2fs_run_ext3_jo.patch
|
||||||
|
Patch20: 0020-tune2fs-tune2fs_main-should-return-rc-when-some-erro.patch
|
||||||
|
Patch21: 0021-tune2fs-exit-directly-when-fs-freed-in-ext2fs_run_ext3_journal.patch
|
||||||
|
|
||||||
|
|
||||||
BuildRequires: gcc pkgconfig texinfo
|
BuildRequires: gcc pkgconfig texinfo
|
||||||
@ -166,6 +169,9 @@ exit 0
|
|||||||
%{_mandir}/man8/*
|
%{_mandir}/man8/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Oct 14 2022 Zhiqiang Liu <liuzhiqiang26@huawei.com> - 1.46.4-16
|
||||||
|
- tune2fs: fix segfault problem
|
||||||
|
|
||||||
* Fri Sep 23 2022 zhanchengbin <zhanchengbin1@huawei.com> - 1.46.4-15
|
* Fri Sep 23 2022 zhanchengbin <zhanchengbin1@huawei.com> - 1.46.4-15
|
||||||
- test: fix ACL-printing tests from community
|
- test: fix ACL-printing tests from community
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user