summaryrefslogtreecommitdiff
path: root/e2fsck/e2fsck.h
diff options
context:
space:
mode:
authorAndreas Dilger <adilger@whamcloud.com>2020-02-06 18:09:38 -0700
committerTheodore Ts'o <tytso@mit.edu>2020-02-29 18:24:42 -0500
commit74fbba1ff1074333eedaa3ed46597294641bf6b8 (patch)
tree1ea3ea59fc16e87a0e897dfeda7978963e3a1621 /e2fsck/e2fsck.h
parent336c440ccea8f94b0728f881cddee84f730e7cc7 (diff)
downloade2fsprogs-74fbba1ff1074333eedaa3ed46597294641bf6b8.tar.gz
e2fsck: fix e2fsck_allocate_memory() overflow
e2fsck_allocate_memory() takes an "unsigned int size" argument, which will overflow for allocations above 4GB. This happens for dir_info and dx_dir_info arrays when there are more than 350M directories in a filesystem, and for the dblist array above 180M directories. There is also a risk of overflow during the binary search in both e2fsck_get_dir_info() and e2fsck_get_dx_dir_info() when the midpoint of the array is calculated, if there would be more than 2B directories in the filesystem and working above the half way point. Also, in some places inode numbers are "int" instead of "ext2_ino_t", which can also cause problems with the array size calculations, and makes it hard to identify where inode numbers are used. Fix e2fsck_allocate_memory() to take an "unsigned long" argument to match ext2fs_get_mem(), so that it can do single memory allocations over 4GB. Fix e2fsck_get_dir_info() and e2fsck_get_dx_dir_info() to temporarily use an unsigned long long value to calculate the midpoint (which will always fit into an ext2_ino_t again afterward). Change variables that hold inode numbers to be ext2_ino_t, and print them as unsigned values instead of printing negative inode numbers. Signed-off-by: Andreas Dilger <adilger@whamcloud.com> Reviewed-by: Shilong Wang <wshilong@ddn.com> Lustre-bug-id: https://jira.whamcloud.com/browse/LU-13197 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'e2fsck/e2fsck.h')
-rw-r--r--e2fsck/e2fsck.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
index 2d359b38..253f8b58 100644
--- a/e2fsck/e2fsck.h
+++ b/e2fsck/e2fsck.h
@@ -318,9 +318,9 @@ struct e2fsck_struct {
/*
* Indexed directory information
*/
- int dx_dir_info_count;
- int dx_dir_info_size;
- struct dx_dir_info *dx_dir_info;
+ ext2_ino_t dx_dir_info_count;
+ ext2_ino_t dx_dir_info_size;
+ struct dx_dir_info *dx_dir_info;
/*
* Directories to hash
@@ -595,7 +595,7 @@ int check_backup_super_block(e2fsck_t ctx);
void check_resize_inode(e2fsck_t ctx);
/* util.c */
-extern void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned int size,
+extern void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned long size,
const char *description);
extern int ask(e2fsck_t ctx, const char * string, int def);
extern int ask_yn(e2fsck_t ctx, const char * string, int def);