xfs
[Top] [All Lists]

Re: [PATCH v3] xfs: fix possible overflow in xfs_ioc_trim()

To: Lukas Czerner <lczerner@xxxxxxxxxx>
Subject: Re: [PATCH v3] xfs: fix possible overflow in xfs_ioc_trim()
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Wed, 21 Sep 2011 08:23:13 -0400
Cc: xfs@xxxxxxxxxxx, hch@xxxxxxxxxxxxx
In-reply-to: <1316598150-12447-1-git-send-email-lczerner@xxxxxxxxxx>
References: <1316598150-12447-1-git-send-email-lczerner@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Wed, Sep 21, 2011 at 11:42:30AM +0200, Lukas Czerner wrote:
> In xfs_ioc_trim it is possible that computing the last allocation group
> to discard might overflow for big start & len values, because the result
> might be bigger then xfs_agnumber_t which is 32 bit long. Fix this by not
> allowing the start and end block of the range to be beyond the end of the
> file system.
> 
> Note that if the start is beyond the end of the file system we have to
> return -EINVAL, but in the "end" case we have to truncate it to the fs
> size.
> 
> Also introduce "end" variable, rather than using start+len which which
> might be more confusing to get right as this bug shows.
> 
> Signed-off-by: Lukas Czerner <lczerner@xxxxxxxxxx>

Looks good,

Reviewed-by: Christoph Hellwig <hch@xxxxxx>

<Prev in Thread] Current Thread [Next in Thread>