xfs: check for possible overflow in xfs_ioc_trim
PATCH v4 1/1 xfs: check for possible overflow in xfs_ioc_trim
If range.start or range.minlen is bigger than filesystem size, return invalid value error. This fixes possible overflow in BTOBB macro when passed value was nearly ULLONG_MAX.
--- fs/xfs/xfs_discard.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
fs/xfs/xfs_discard.c +4 -2
@@ -179,12 +179,14 @@ xfs_ioc_trim(* used by the fstrim application. In the end it really doesn't * 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))) +return -XFS_ERROR (EINVAL ); + start =BTOBB (range.start); end = start +BTOBBT (range.len) -1 ; minlen =BTOBB (max_t (u64, granularity, range.minlen)); -if (XFS_BB_TO_FSB (mp, start) >= mp->m_sb.sb_dblocks) -return -XFS_ERROR (EINVAL );if (end >XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks) -1 ) end =XFS_FSB_TO_BB (mp, mp->m_sb.sb_dblocks)-1 ;
Signature · 6 lines
1.7.7.6 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 5 lines · Tomas Racek
If range.start or range.minlen is bigger than filesystem size, return invalid value error. This fixes possible overflow in BTOBB macro when passed value was nearly
ULLONG_MAX.Signed-off-by Tomas Racek <[email protected]>
looks ok to me.
Signature · 7 lines
Dave Chinner [email protected] _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Forwarding to maintainers.
----- Original Message -----
Quoted 7 lines · Tomas Racek
Quoted 6 lines
If range.start or range.minlen is bigger than filesystem size, return
invalid value error. This fixes possible overflow in BTOBB macro when
passed value was nearlyULLONG_MAX.
Quoted 9 lines
Quoted 1 line
Signed-off-by Tomas Racek <[email protected]>looks ok to me.
Reviewed-by Dave Chinner <[email protected]>--
Dave Chinner
[email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Quoted 1 line · Tomas Racek
Forwarding to maintainers.
Thanks Tomas. We'll get this sorted.
Regards,
Ben
Quoted 18 lines
----- Original Message -----
Quoted 16 lines · Tomas Racek
Quoted 7 lines
If range.start or range.minlen is bigger than filesystem size, return
invalid value error. This fixes possible overflow in BTOBB macro when
passed value was nearlyULLONG_MAX.Signed-off-by Tomas Racek <[email protected]>looks ok to me.
Reviewed-by Dave Chinner <[email protected]>--
Dave Chinner
[email protected]
_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs