2010-07-15 18:47:18

by Kulikov Vasiliy

[permalink] [raw]
Subject: [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.

Signed-off-by: Kulikov Vasiliy <[email protected]>
---
fs/xfs/xfs_vnodeops.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index 65e0879..66d585c 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -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);
--
1.7.0.4


2010-07-15 21:21:20

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH 6/8] xfs: fix unsigned underflow

On Thu, Jul 15, 2010 at 10:46:45PM +0400, Kulikov Vasiliy wrote:
> map_len is unsigned. Checking map_len <= 0 is buggy when it should be
> below zero. So, check exact expression instead of map_len.
>
> Signed-off-by: Kulikov Vasiliy <[email protected]>

Looks good,


Reviewed-by: Christoph Hellwig <[email protected]>

2010-07-20 19:35:36

by Alex Elder

[permalink] [raw]
Subject: Re: [PATCH 6/8] xfs: fix unsigned underflow

On Thu, 2010-07-15 at 17:21 -0400, Christoph Hellwig wrote:
> On Thu, Jul 15, 2010 at 10:46:45PM +0400, Kulikov Vasiliy wrote:
> > map_len is unsigned. Checking map_len <= 0 is buggy when it should be
> > below zero. So, check exact expression instead of map_len.
> >
> > Signed-off-by: Kulikov Vasiliy <[email protected]>
>
> Looks good,
>
> Reviewed-by: Christoph Hellwig <[email protected]>
>

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

-Alex

2010-07-20 20:22:10

by Kulikov Vasiliy

[permalink] [raw]
Subject: Re: [PATCH 6/8] xfs: fix unsigned underflow

On Tue, Jul 20, 2010 at 14:35 -0500, Alex Elder wrote:
> On Thu, 2010-07-15 at 17:21 -0400, Christoph Hellwig wrote:
> > On Thu, Jul 15, 2010 at 10:46:45PM +0400, Kulikov Vasiliy wrote:
> > > map_len is unsigned. Checking map_len <= 0 is buggy when it should be
> > > below zero. So, check exact expression instead of map_len.
> > >
> > > Signed-off-by: Kulikov Vasiliy <[email protected]>
> >
> > Looks good,
> >
> > Reviewed-by: Christoph Hellwig <[email protected]>
> >
>
> 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.

>
> -Alex
>

2010-07-20 23:12:12

by Dave Chinner

[permalink] [raw]
Subject: Re: [PATCH 6/8] xfs: fix unsigned underflow

On Tue, Jul 20, 2010 at 02:35:33PM -0500, Alex Elder wrote:
> On Thu, 2010-07-15 at 17:21 -0400, Christoph Hellwig wrote:
> > On Thu, Jul 15, 2010 at 10:46:45PM +0400, Kulikov Vasiliy wrote:
> > > map_len is unsigned. Checking map_len <= 0 is buggy when it should be
> > > below zero. So, check exact expression instead of map_len.
> > >
> > > Signed-off-by: Kulikov Vasiliy <[email protected]>
> >
> > Looks good,
> >
> > Reviewed-by: Christoph Hellwig <[email protected]>
> >
>
> 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.
--
Dave Chinner
[email protected]