From: Brian Foster Date: Thu, 5 Feb 2015 23:32:32 +0000 (+1100) Subject: repair: check ino alignment value to avoid mod by zero X-Git-Tag: v3.2.3-rc1~33 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ca0a799ea95aceca7eda2c89d7a06549a4333cab;p=thirdparty%2Fxfsprogs-dev.git repair: check ino alignment value to avoid mod by zero xfs_repair checks inode records for valid alignment according to the alignment specified in the superblock. It currently performs the alignment check whenever fs_aligned_inodes is set, which is determined based on whether the fs supports the field. Support for the field does not guarantee its value is non-zero, however. For example, a large block size fs on a large page size arch (e.g., ppc64): mkfs.xfs -f -m crc=1,finobt=1 -b size=64k ... can lead to incorrect badly aligned inode record messages from xfs_repair and other problems. Update the inobt and finobt checks to verify that alignment is a non-zero value before attempting to use it to divide (mod) by zero. Signed-off-by: Brian Foster Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- diff --git a/repair/scan.c b/repair/scan.c index 142d8d783..ce8d7f5f8 100644 --- a/repair/scan.c +++ b/repair/scan.c @@ -770,7 +770,8 @@ scan_single_ino_chunk( (inodes_per_block <= XFS_INODES_PER_CHUNK && off != 0) || (inodes_per_block > XFS_INODES_PER_CHUNK && off % XFS_INODES_PER_CHUNK != 0) || - (fs_aligned_inodes && agbno % fs_ino_alignment != 0)) { + (fs_aligned_inodes && fs_ino_alignment && + agbno % fs_ino_alignment != 0)) { do_warn( _("badly aligned inode rec (starting inode = %" PRIu64 ")\n"), lino); @@ -929,7 +930,8 @@ scan_single_finobt_chunk( (inodes_per_block <= XFS_INODES_PER_CHUNK && off != 0) || (inodes_per_block > XFS_INODES_PER_CHUNK && off % XFS_INODES_PER_CHUNK != 0) || - (fs_aligned_inodes && agbno % fs_ino_alignment != 0)) { + (fs_aligned_inodes && fs_ino_alignment && + agbno % fs_ino_alignment != 0)) { do_warn( _("badly aligned finobt inode rec (starting inode = %" PRIu64 ")\n"), lino);