* [PATCH v2] xfs: avoid underflow in xfs_ioc_trim()
@ 2012-10-11 8:33 Lukas Czerner
2012-10-11 21:35 ` Dave Chinner
0 siblings, 1 reply; 4+ messages in thread
From: Lukas Czerner @ 2012-10-11 8:33 UTC (permalink / raw)
To: xfs; +Cc: Lukas Czerner
Currently if len argument in xfs_ioc_trim() is smaller than one FSB
the 'end' variable underflow. Avoid that by returning EINVAL when
range is smaller than FSB.
Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
v2: reworked, return EINVAL if len < FSB
fs/xfs/xfs_discard.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c
index 69cf4fc..04ddbbb 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.7.7.6
_______________________________________________
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 v2] xfs: avoid underflow in xfs_ioc_trim()
2012-10-11 8:33 [PATCH v2] xfs: avoid underflow in xfs_ioc_trim() Lukas Czerner
@ 2012-10-11 21:35 ` Dave Chinner
2012-10-12 5:35 ` Lukáš Czerner
0 siblings, 1 reply; 4+ messages in thread
From: Dave Chinner @ 2012-10-11 21:35 UTC (permalink / raw)
To: Lukas Czerner; +Cc: xfs
On Thu, Oct 11, 2012 at 10:33:52AM +0200, Lukas Czerner wrote:
> Currently if len argument in xfs_ioc_trim() is smaller than one FSB
> the 'end' variable underflow. Avoid that by returning EINVAL when
> range is smaller than FSB.
>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Just a thought - wouldn't this be better done at the VFS so it is
consistent across all filesystems? i.e. using inode->i_blkbits?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
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 v2] xfs: avoid underflow in xfs_ioc_trim()
2012-10-11 21:35 ` Dave Chinner
@ 2012-10-12 5:35 ` Lukáš Czerner
2012-10-12 5:49 ` Dave Chinner
0 siblings, 1 reply; 4+ messages in thread
From: Lukáš Czerner @ 2012-10-12 5:35 UTC (permalink / raw)
To: Dave Chinner; +Cc: Lukas Czerner, xfs
On Fri, 12 Oct 2012, Dave Chinner wrote:
> Date: Fri, 12 Oct 2012 08:35:33 +1100
> From: Dave Chinner <david@fromorbit.com>
> To: Lukas Czerner <lczerner@redhat.com>
> Cc: xfs@oss.sgi.com
> Subject: Re: [PATCH v2] xfs: avoid underflow in xfs_ioc_trim()
>
> On Thu, Oct 11, 2012 at 10:33:52AM +0200, Lukas Czerner wrote:
> > Currently if len argument in xfs_ioc_trim() is smaller than one FSB
> > the 'end' variable underflow. Avoid that by returning EINVAL when
> > range is smaller than FSB.
> >
> > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
>
> Just a thought - wouldn't this be better done at the VFS so it is
> consistent across all filesystems? i.e. using inode->i_blkbits?
>
> Cheers,
>
> Dave.
Currently I am working on patches for other file system, so we'll
get it fix. Having the check in VFS would require to make FITRIM
file system (inode?) operation, or adding cmd specific sections to
the vfs_ioctl(). All of this just for one check and file system
implementation would have to do other check anyway because we can
hardly do all of that in VFS. So I think it's not worth it.
Thanks!
-Lukas
_______________________________________________
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 v2] xfs: avoid underflow in xfs_ioc_trim()
2012-10-12 5:35 ` Lukáš Czerner
@ 2012-10-12 5:49 ` Dave Chinner
0 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2012-10-12 5:49 UTC (permalink / raw)
To: Lukáš Czerner; +Cc: xfs
On Fri, Oct 12, 2012 at 07:35:39AM +0200, Lukáš Czerner wrote:
> On Fri, 12 Oct 2012, Dave Chinner wrote:
>
> > Date: Fri, 12 Oct 2012 08:35:33 +1100
> > From: Dave Chinner <david@fromorbit.com>
> > To: Lukas Czerner <lczerner@redhat.com>
> > Cc: xfs@oss.sgi.com
> > Subject: Re: [PATCH v2] xfs: avoid underflow in xfs_ioc_trim()
> >
> > On Thu, Oct 11, 2012 at 10:33:52AM +0200, Lukas Czerner wrote:
> > > Currently if len argument in xfs_ioc_trim() is smaller than one FSB
> > > the 'end' variable underflow. Avoid that by returning EINVAL when
> > > range is smaller than FSB.
> > >
> > > Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> >
> > Just a thought - wouldn't this be better done at the VFS so it is
> > consistent across all filesystems? i.e. using inode->i_blkbits?
> >
> > Cheers,
> >
> > Dave.
>
> Currently I am working on patches for other file system, so we'll
> get it fix. Having the check in VFS would require to make FITRIM
> file system (inode?) operation
Not at all - filp->mapping->host gets you the inode....
>
> , or adding cmd specific sections to
> the vfs_ioctl().
But that's a fair reason not to....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
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:[~2012-10-12 5:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-11 8:33 [PATCH v2] xfs: avoid underflow in xfs_ioc_trim() Lukas Czerner
2012-10-11 21:35 ` Dave Chinner
2012-10-12 5:35 ` Lukáš Czerner
2012-10-12 5:49 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox