public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH] xfstests: fix modulo-by-zero error in fsx
Date: Tue, 19 Jul 2011 13:49:13 +1000	[thread overview]
Message-ID: <1311047353-23925-1-git-send-email-david@fromorbit.com> (raw)

From: Dave Chinner <dchinner@redhat.com>

The recent fsx fixes has a logic error in the offset trimming code.
If a read is done when the file size is zero, then the logic error
causes a offset % 0 opertaion to occur. This causes fsx to get a
SIGFPE and die.

This was not discovered during my testing because I was using a
random seed that didn't trip this condition. Changing the seed to
that which test 091 uses (the default of 1) causes such an operation
to occur....

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 ltp/fsx.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ltp/fsx.c b/ltp/fsx.c
index 771bcdc..d53c498 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -987,14 +987,14 @@ docloseopen(void)
 	}
 }
 
-#define TRIM_OFF_LEN(off, len, size, zero_offset)	\
-do {					\
-	if (!zero_offset || file_size)	\
-		offset %= size;		\
-	else				\
-		offset = 0;		\
-	if (offset + len > size)	\
-		len = size - offset;	\
+#define TRIM_OFF_LEN(off, len, size, allow_zero_file_size)	\
+do {						\
+	if (allow_zero_file_size || file_size)	\
+		offset %= size;			\
+	else					\
+		offset = 0;			\
+	if (offset + len > size)		\
+		len = size - offset;		\
 } while (0)
 
 void
-- 
1.7.5.1

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

             reply	other threads:[~2011-07-19  3:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-19  3:49 Dave Chinner [this message]
2011-07-19 17:10 ` [PATCH] xfstests: fix modulo-by-zero error in fsx Christoph Hellwig
2011-07-20 23:04 ` Alex Elder
2011-07-20 23:13   ` Dave Chinner
2011-07-24 12:41 ` Christoph Hellwig

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=1311047353-23925-1-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.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