Skip to contentSkip to conversation

xfs: fix unsigned underflow

PATCH Applied Kulikov Vasiliy 4 participants 5 messages Jul 15, 2010 – Jul 20, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/8 xfs: fix unsigned underflow

map_len is unsigned. Checking map_len <= 0 is buggy when it should be below zero. So, check exact expression instead of map_len.

---
 fs/xfs/xfs_vnodeops.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_vnodeops.c +2 -2
index 65e0879..66d585c 100644
@@ -591,9 +591,9 @@ xfs_free_eofblocks(
 	 */
 	end_fsb = XFS_B_TO_FSB(mp, ((xfs_ufsize_t)ip->i_size));
 	last_fsb = XFS_B_TO_FSB(mp, (xfs_ufsize_t)XFS_MAXIOFFSET(mp));
-	map_len = last_fsb - end_fsb;
-	if (map_len <= 0)
+	if (last_fsb <= end_fsb)
 		return 0;
+	map_len = last_fsb - end_fsb;
 
 	nimaps = 1;
 	xfs_ilock(ip, XFS_ILOCK_SHARED);
Signature · 6 lines
1.7.0.4

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Kulikov Vasiliy

map_len is unsigned. Checking map_len <= 0 is buggy when it should be below zero. So, check exact expression instead of map_len.

Looks good,

Looks good to me too. Do you want me to pull this in via the XFS tree, or do you have other plans?

-Alex

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
Quoted 7 lines · Alex Elder
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Kulikov Vasiliy

map_len is unsigned. Checking map_len <= 0 is buggy when it should be below zero. So, check exact expression instead of map_len.

Quoted 7 lines
Quoted 4 lines

Looks good,

Looks good to me too. Do you want me to pull this in via the XFS tree, or do you have other plans?

Yes, pull it please.

Quoted 3 lines

-Alex

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
In reply to Alex Elder
Quoted 7 lines · Alex Elder
Quoted 6 lines · Christoph Hellwig
Quoted 4 lines · Kulikov Vasiliy

map_len is unsigned. Checking map_len <= 0 is buggy when it should be below zero. So, check exact expression instead of map_len.

Quoted 7 lines
Quoted 4 lines

Looks good,

Looks good to me too. Do you want me to pull this in via the XFS tree, or do you have other plans?

Already got it, Alex.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs