public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim()
@ 2013-12-11 12:05 Lukas Czerner
  2013-12-11 13:10 ` Jeff Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Lukas Czerner @ 2013-12-11 12:05 UTC (permalink / raw)
  To: xfs; +Cc: Lukas Czerner

Currently when range.len is set to 0 it will underflow. Fix it by
checking for this scenario and return EINVAL in case range.len is
smaller than block size.

This was discovered by the xfstests generic/288 and with this patch
the problem goes away.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 fs/xfs/xfs_discard.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 8367d6d..9029082 100644
--- a/fs/xfs/xfs_discard.c
+++ b/fs/xfs/xfs_discard.c
@@ -180,7 +180,8 @@ xfs_ioc_trim(
 	 * matter as trimming blocks is an advisory interface.
 	 */
 	if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) ||
-	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)))
+	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) ||
+	    range.len < XFS_FSB_TO_B(mp, 1))
 		return -XFS_ERROR(EINVAL);
 
 	start = BTOBB(range.start);
-- 
1.8.3.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim()
  2013-12-11 12:05 [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim() Lukas Czerner
@ 2013-12-11 13:10 ` Jeff Liu
  2013-12-11 13:20   ` Lukáš Czerner
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Liu @ 2013-12-11 13:10 UTC (permalink / raw)
  To: Lukas Czerner, xfs

Hi Lukas,

Thanks for the fix.  We have corrected this problem with the blow patch
which got merged intwo weeks ago. :)
[ commit f9fd013561 ]
xfs: don't perform discard if the given range length is less than block size

That is also discovered by generic/288 you contributed.

Thanks,
-Jeff

On 12/11 2013 20:05 PM, Lukas Czerner wrote:
> Currently when range.len is set to 0 it will underflow. Fix it by
> checking for this scenario and return EINVAL in case range.len is
> smaller than block size.
> 
> This was discovered by the xfstests generic/288 and with this patch
> the problem goes away.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> ---
>  fs/xfs/xfs_discard.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> index 8367d6d..9029082 100644
> --- a/fs/xfs/xfs_discard.c
> +++ b/fs/xfs/xfs_discard.c
> @@ -180,7 +180,8 @@ xfs_ioc_trim(
>  	 * matter as trimming blocks is an advisory interface.
>  	 */
>  	if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) ||
> -	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)))
> +	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) ||
> +	    range.len < XFS_FSB_TO_B(mp, 1))
>  		return -XFS_ERROR(EINVAL);
>  
>  	start = BTOBB(range.start);
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim()
  2013-12-11 13:10 ` Jeff Liu
@ 2013-12-11 13:20   ` Lukáš Czerner
  2013-12-11 13:25     ` Jeff Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Lukáš Czerner @ 2013-12-11 13:20 UTC (permalink / raw)
  To: Jeff Liu; +Cc: xfs

On Wed, 11 Dec 2013, Jeff Liu wrote:

> Date: Wed, 11 Dec 2013 21:10:48 +0800
> From: Jeff Liu <jeff.liu@oracle.com>
> To: Lukas Czerner <lczerner@redhat.com>, xfs@oss.sgi.com
> Subject: Re: [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim()
> 
> Hi Lukas,
> 
> Thanks for the fix.  We have corrected this problem with the blow patch
> which got merged intwo weeks ago. :)
> [ commit f9fd013561 ]

Not sure where it got merged, I do not see this upstream in linus
tree.

> xfs: don't perform discard if the given range length is less than block size
> 
> That is also discovered by generic/288 you contributed.

Right, I mentioned that in the description.

-Lukas

> 
> Thanks,
> -Jeff
> 
> On 12/11 2013 20:05 PM, Lukas Czerner wrote:
> > Currently when range.len is set to 0 it will underflow. Fix it by
> > checking for this scenario and return EINVAL in case range.len is
> > smaller than block size.
> > 
> > This was discovered by the xfstests generic/288 and with this patch
> > the problem goes away.
> > 
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> > ---
> >  fs/xfs/xfs_discard.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
> > index 8367d6d..9029082 100644
> > --- a/fs/xfs/xfs_discard.c
> > +++ b/fs/xfs/xfs_discard.c
> > @@ -180,7 +180,8 @@ xfs_ioc_trim(
> >  	 * matter as trimming blocks is an advisory interface.
> >  	 */
> >  	if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) ||
> > -	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)))
> > +	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) ||
> > +	    range.len < XFS_FSB_TO_B(mp, 1))
> >  		return -XFS_ERROR(EINVAL);
> >  
> >  	start = BTOBB(range.start);
> > 
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim()
  2013-12-11 13:20   ` Lukáš Czerner
@ 2013-12-11 13:25     ` Jeff Liu
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Liu @ 2013-12-11 13:25 UTC (permalink / raw)
  To: Lukáš Czerner; +Cc: xfs


On 12/11 2013 21:20 PM, Lukáš Czerner wrote:
> On Wed, 11 Dec 2013, Jeff Liu wrote:
> 
>> Date: Wed, 11 Dec 2013 21:10:48 +0800
>> From: Jeff Liu <jeff.liu@oracle.com>
>> To: Lukas Czerner <lczerner@redhat.com>, xfs@oss.sgi.com
>> Subject: Re: [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim()
>>
>> Hi Lukas,
>>
>> Thanks for the fix.  We have corrected this problem with the blow patch
>> which got merged intwo weeks ago. :)
>> [ commit f9fd013561 ]
> 
> Not sure where it got merged, I do not see this upstream in linus
> tree.
Now it resides in xfs-next tree, but I remember Ben have sent out the
pull request "[GIT PULL] XFS bugfixes for 3.13-rc4" to Linus yesterday.

Thanks,
-Jeff
> 
>> xfs: don't perform discard if the given range length is less than block size
>>
>> That is also discovered by generic/288 you contributed.
> 
> Right, I mentioned that in the description.
> 
> -Lukas
> 
>>
>> Thanks,
>> -Jeff
>>
>> On 12/11 2013 20:05 PM, Lukas Czerner wrote:
>>> Currently when range.len is set to 0 it will underflow. Fix it by
>>> checking for this scenario and return EINVAL in case range.len is
>>> smaller than block size.
>>>
>>> This was discovered by the xfstests generic/288 and with this patch
>>> the problem goes away.
>>>
>>> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
>>> ---
>>>  fs/xfs/xfs_discard.c | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
>>> index 8367d6d..9029082 100644
>>> --- a/fs/xfs/xfs_discard.c
>>> +++ b/fs/xfs/xfs_discard.c
>>> @@ -180,7 +180,8 @@ xfs_ioc_trim(
>>>  	 * matter as trimming blocks is an advisory interface.
>>>  	 */
>>>  	if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks) ||
>>> -	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)))
>>> +	    range.minlen > XFS_FSB_TO_B(mp, XFS_ALLOC_AG_MAX_USABLE(mp)) ||
>>> +	    range.len < XFS_FSB_TO_B(mp, 1))
>>>  		return -XFS_ERROR(EINVAL);
>>>  
>>>  	start = BTOBB(range.start);
>>>
>>
> 
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
> 

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-11 13:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-11 12:05 [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim() Lukas Czerner
2013-12-11 13:10 ` Jeff Liu
2013-12-11 13:20   ` Lukáš Czerner
2013-12-11 13:25     ` Jeff Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox