From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id DC843802F for ; Wed, 11 Dec 2013 07:25:22 -0600 (CST) Received: from cuda.sgi.com (cuda3.sgi.com [192.48.176.15]) by relay1.corp.sgi.com (Postfix) with ESMTP id C31EB8F8054 for ; Wed, 11 Dec 2013 05:25:22 -0800 (PST) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by cuda.sgi.com with ESMTP id 0omwCkhbsIciaKTW (version=TLSv1 cipher=AES256-SHA bits=256 verify=NO) for ; Wed, 11 Dec 2013 05:25:21 -0800 (PST) Message-ID: <52A867B7.2040208@oracle.com> Date: Wed, 11 Dec 2013 21:25:11 +0800 From: Jeff Liu MIME-Version: 1.0 Subject: Re: [PATCH] xfs: prevent range.len underflow in xfs_ioc_trim() References: <1386763525-18584-1-git-send-email-lczerner@redhat.com> <52A86458.9030001@oracle.com> In-Reply-To: List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com To: =?windows-1252?Q?Luk=E1=9A_Czerner?= Cc: xfs@oss.sgi.com On 12/11 2013 21:20 PM, Luk=E1=9A Czerner wrote: > On Wed, 11 Dec 2013, Jeff Liu wrote: > = >> Date: Wed, 11 Dec 2013 21:10:48 +0800 >> From: Jeff Liu >> To: Lukas Czerner , 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 >>> --- >>> 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 >=3D 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 =3D 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