public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH 2/2] repair: check ino alignment value to avoid mod by zero
Date: Thu,  5 Feb 2015 16:50:23 -0500	[thread overview]
Message-ID: <1423173023-54866-3-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1423173023-54866-1-git-send-email-bfoster@redhat.com>

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 <dev>

... 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 <bfoster@redhat.com>
---
 repair/scan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/repair/scan.c b/repair/scan.c
index 142d8d7..ce8d7f5 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);
-- 
1.8.3.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2015-02-05 21:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 21:50 [PATCH 0/2] xfsprogs/repair: fix a couple large block size alignment issues Brian Foster
2015-02-05 21:50 ` [PATCH 1/2] repair: fix v5 sb ino alignment calculation for large blocksizes Brian Foster
2015-02-05 21:50 ` Brian Foster [this message]
2015-02-05 23:37 ` [PATCH 0/2] xfsprogs/repair: fix a couple large block size alignment issues Dave Chinner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1423173023-54866-3-git-send-email-bfoster@redhat.com \
    --to=bfoster@redhat.com \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox