If a user crafts a carefully constructed filesystem containing a single directory entry block with an invalid checksum and fewer than two entries, and then runs e2fsck to fix the filesystem, fsck will crash when it tries to "compress" the short dir and passes a negative dirent array length to qsort. Therefore, don't allow directory "compression" in this situation. Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx> --- e2fsck/rehash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index f75479a..5913ae7 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -848,7 +848,7 @@ retry_nohash: /* Sort the list */ resort: - if (fd.compress) + if (fd.compress && fd.num_array > 1) qsort(fd.harray+2, fd.num_array-2, sizeof(struct hash_entry), hash_cmp); else @@ -867,7 +867,7 @@ resort: } /* Sort non-hashed directories by inode number */ - if (fd.compress) + if (fd.compress && fd.num_array > 1) qsort(fd.harray+2, fd.num_array-2, sizeof(struct hash_entry), ino_cmp); -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html