[Top] [All Lists]

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

To: Alex Elder <aelder@xxxxxxx>
Subject: Re: [PATCH v3] xfs: fix possible overflow in xfs_ioc_trim()
From: Lukas Czerner <lczerner@xxxxxxxxxx>
Date: Fri, 23 Sep 2011 19:17:07 +0200 (CEST)
Cc: Lukas Czerner <lczerner@xxxxxxxxxx>, xfs@xxxxxxxxxxx, hch@xxxxxxxxxxxxx
In-reply-to: <1316797735.2879.69.camel@doink>
References: <1316598150-12447-1-git-send-email-lczerner@xxxxxxxxxx> <1316797735.2879.69.camel@doink>
User-agent: Alpine 2.00 (LFD 1167 2008-08-23)
On Fri, 23 Sep 2011, Alex Elder wrote:

> On Wed, 2011-09-21 at 11:42 +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>
> There are cases where we're (still) not trimming
> blocks within the range specified when we could.
> I have an idea about how to do that but I'll send
> it out later and will commit this as-is.

What cases do you have in mind ? I have actually noticed that you are
discarding even more than user asked for in case that the free extent
and the range to trim overlaps, but that perfectly fine since the
duration of the discard command does not usually depends on the extent
size, so it is good thing to do.

> Reviewed-by: Alex Elder <aelder@xxxxxxx>


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