diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c index d056314d..e05bf6f9 100644 --- a/e2fsck/pass1.c +++ b/e2fsck/pass1.c @@ -2456,6 +2456,17 @@ static int process_block(ext2_filsys fs, blk = *block_nr = 0; ret_code = BLOCK_CHANGED; p->inode_modified = 1; + /* + * If the directory block is too big and is beyond the + * end of the FS, don't bother trying to add it for + * processing -- the kernel would never have created a + * directory this large, and we risk an ENOMEM abort. + * In any case, the toobig handler for extent-based + * directories also doesn't feed toobig blocks to + * pass 2. + */ + if (problem == PR_1_TOOBIG_DIR) + return ret_code; goto mark_dir; } else return 0; diff --git a/tests/f_hugedir_blocks/expect.1 b/tests/f_hugedir_blocks/expect.1 new file mode 100644 index 00000000..798a7ac8 --- /dev/null +++ b/tests/f_hugedir_blocks/expect.1 @@ -0,0 +1,10 @@ +Pass 1: Checking inodes, blocks, and sizes +Inode 12 is too big. Truncate? yes + +Block #1074791435 (13) causes directory to be too big. CLEARED. +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 12/128 files (8.3% non-contiguous), 22/512 blocks +Exit status is 0 diff --git a/tests/f_hugedir_blocks/expect.2 b/tests/f_hugedir_blocks/expect.2 new file mode 100644 index 00000000..ac5f4c13 --- /dev/null +++ b/tests/f_hugedir_blocks/expect.2 @@ -0,0 +1,7 @@ +Pass 1: Checking inodes, blocks, and sizes +Pass 2: Checking directory structure +Pass 3: Checking directory connectivity +Pass 4: Checking reference counts +Pass 5: Checking group summary information +test_filesys: 12/128 files (8.3% non-contiguous), 22/512 blocks +Exit status is 0 diff --git a/tests/f_hugedir_blocks/image.gz b/tests/f_hugedir_blocks/image.gz new file mode 100644 index 00000000..1d54de80 Binary files /dev/null and b/tests/f_hugedir_blocks/image.gz differ diff --git a/tests/f_hugedir_blocks/name b/tests/f_hugedir_blocks/name new file mode 100644 index 00000000..d74761b4 --- /dev/null +++ b/tests/f_hugedir_blocks/name @@ -0,0 +1 @@ +crash e2fsck with a dir with an impossibly high logical blk offset