public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [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

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