From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id p87BLvd7154431 for ; Wed, 7 Sep 2011 06:21:57 -0500 Received: from bombadil.infradead.org (localhost [127.0.0.1]) by cuda.sgi.com (Spam Firewall) with ESMTP id 7F8C41419D5 for ; Wed, 7 Sep 2011 04:21:56 -0700 (PDT) Received: from bombadil.infradead.org (173-166-109-252-newengland.hfc.comcastbusiness.net [173.166.109.252]) by cuda.sgi.com with ESMTP id FRwyvgahoT9IiAJ7 for ; Wed, 07 Sep 2011 04:21:56 -0700 (PDT) Date: Wed, 7 Sep 2011 07:21:55 -0400 From: Christoph Hellwig Subject: Re: [PATCH v2] xfs: fix possible overflow in xfs_ioc_trim() Message-ID: <20110907112155.GA1017@infradead.org> References: <1315322977-22736-1-git-send-email-lczerner@redhat.com> <20110906153301.GA21675@infradead.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: xfs-bounces@oss.sgi.com Errors-To: xfs-bounces@oss.sgi.com To: Lukas Czerner Cc: Christoph Hellwig , xfs@oss.sgi.com On Wed, Sep 07, 2011 at 12:05:14PM +0200, Lukas Czerner wrote: > > > + if (len > max_blks) > > > + len = max_blks - start; > > > > Is this really the correct check? > > > > Shouldn't it be > > > > if (start + len > max_blks) > > len = max_blks - start; > > > > I'd also just use the mp->m_sb.sb_dblocks value directly instead > > of assigning it to a local variable. > > > > Agh, you're right. I am bit too hasty I guess. I thought that > > if (start_agno >= mp->m_sb.sb_agcount) > return -XFS_ERROR(EINVAL); > > will cover us from the unreasonably big start, however if the file > system has really huge number of AGs than it will fail to prevent the > overflow, I am not sure if that is possible to happen, but what you > proposed is definitely better. The problem is that start could be very far into the fs, so checking len alone won't help very much. And we probably want a check if start + len is overflowing, too. Care to update the test case to cover these cases as well? _______________________________________________ xfs mailing list xfs@oss.sgi.com http://oss.sgi.com/mailman/listinfo/xfs