!80 e2fsck: handle->level is overflow in ext2fs_extent_get.

From: @hifi521 
Reviewed-by: @liuzhiqiang26 
Signed-off-by: @liuzhiqiang26
This commit is contained in:
openeuler-ci-bot 2022-05-20 10:03:07 +00:00 committed by Gitee
commit 4f1bace9f6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 79 additions and 1 deletions

View File

@ -0,0 +1,74 @@
From 508b1b57f73a49effc975731f8b76325d45b0e0f Mon Sep 17 00:00:00 2001
From: zhanchengbin <zhanchengbin1@huawei.com>
Date: Fri, 18 Mar 2022 00:02:50 +0800
Subject: [PATCH] e2fsck: handle->level is overflow in ext2fs_extent_get.
In function check_blocks_extents, program call scan_extent_node recursively until
leaf extent is found, and if this leaf extent is the last one in this extent_idx,
it will delete the parent extent_idx of this leaf extent in ext2fs_extent_delete,
and do handle->level--. After scan_extent_node return, program allways to get up extent,
but level was already decreased.
So calling ext2fs_extent_get(EXT2_EXTENT_UP) again will return EXT2_ET_EXTENT_NO_UP,
and then print failed.
Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
---
e2fsck/pass1.c | 7 +++++++
lib/ext2fs/ext2fs.h | 1 +
lib/ext2fs/extent.c | 5 +++++
3 files changed, 13 insertions(+)
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index 26b9ab71..3d698934 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -3074,11 +3074,18 @@ report_problem:
}
}
}
+
+ int level_bak = ext2fs_current_level_get(ehandle);
+
scan_extent_node(ctx, pctx, pb, extent.e_lblk,
last_lblk, eof_block, ehandle,
next_try_repairs);
if (pctx->errcode)
return;
+
+ if (level_bak != ext2fs_current_level_get(ehandle))
+ return;
+
pctx->errcode = ext2fs_extent_get(ehandle,
EXT2_EXTENT_UP, &extent);
if (pctx->errcode) {
diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 68f9c1fe..d0468f11 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -1333,6 +1333,7 @@ extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
extern void ext2fs_extent_free(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_get(ext2_extent_handle_t handle,
int flags, struct ext2fs_extent *extent);
+extern int ext2fs_current_level_get(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_node_split(ext2_extent_handle_t handle);
extern errcode_t ext2fs_extent_replace(ext2_extent_handle_t handle, int flags,
struct ext2fs_extent *extent);
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index b324c7b0..07acd4e0 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -575,6 +575,11 @@ retry:
return 0;
}
+int ext2fs_current_level_get(ext2_extent_handle_t handle)
+{
+ return handle->level;
+}
+
static errcode_t update_path(ext2_extent_handle_t handle)
{
blk64_t blk;
--
2.27.0

View File

@ -1,6 +1,6 @@
Name: e2fsprogs Name: e2fsprogs
Version: 1.46.4 Version: 1.46.4
Release: 8 Release: 9
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/
@ -19,6 +19,7 @@ Patch10: 0010-tests-update-expect-file-for-u_direct_io.patch
Patch11: 0011-libext2fs-don-t-old-the-CACHE_MTX-while-doing-I-O.patch Patch11: 0011-libext2fs-don-t-old-the-CACHE_MTX-while-doing-I-O.patch
Patch12: 0012-tests-skip-m_rootdir_acl-if-selinux-is-not-disabled.patch Patch12: 0012-tests-skip-m_rootdir_acl-if-selinux-is-not-disabled.patch
Patch13: 0013-e2fsck-do-not-clean-up-file-acl-if-the-inode-is-trun.patch Patch13: 0013-e2fsck-do-not-clean-up-file-acl-if-the-inode-is-trun.patch
Patch14: 0014-e2fsck-handle-level-is-overflow-in-ext2fs_extent_get.patch
BuildRequires: gcc pkgconfig texinfo BuildRequires: gcc pkgconfig texinfo
@ -141,6 +142,9 @@ exit 0
%{_mandir}/man8/* %{_mandir}/man8/*
%changelog %changelog
* Fri May 20 2022 zhanchengbin <zhanchengbin1@huawei.com> - 1.46.4-9
- e2fsck: handle->level is overflow in ext2fs_extent_get.
* Wed May 18 2022 zhanchengbin <zhanchengbin1@huawei.com> - 1.46.4-8 * Wed May 18 2022 zhanchengbin <zhanchengbin1@huawei.com> - 1.46.4-8
- e2fsck: do not clean up file acl if the inode is truncating type - e2fsck: do not clean up file acl if the inode is truncating type