xfstests: fix modulo-by-zero error in fsx
PATCH 1/1 xfstests: fix modulo-by-zero error in fsx
From: Dave Chinner <[email protected]>
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....
--- ltp/fsx.c | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
ltp/fsx.c +8 -8
@@ -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
Signature · 6 lines
1.7.5.1 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 11 lines · Dave Chinner
From: Dave Chinner <[email protected]>
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....
Looks good,
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
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.
Quoted 6 lines
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 <[email protected]>
I realize you already committed this, but I'm finally getting around to reviewing it.
I started composing this message, explaining how you should have done something differently. But at this point it'll be more constructive to just send a patch against what you have already committed. So that will be coming shortly...
-Alex
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 15 lines · Alex Elder
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
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.
Quoted 6 lines
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 <[email protected]>
Quoted 8 lines
I realize you already committed this, but I'm finally getting around to reviewing it.
I started composing this message, explaining how you should have done something differently. But at this point it'll be more constructive to just send a patch against what you have already committed. So that will be coming shortly...
Yeah, better to have something working that perfect. Feel free to make it better ;)
Cheers,
Dave.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
I still get fairly regular 091 failures on my 32-bit userspace VM after this. The interesting thing is that fsx tells we have a mismatch of the junk vs junk.fsxgood files, but when looking at them using diff or cmp they actually are identical.
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs