X-Spam-Checker-Version: SpamAssassin 3.4.0-r929098 (2010-03-30) on oss.sgi.com X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.4.0-r929098 Received: from cuda.sgi.com (cuda1.sgi.com [192.48.157.11]) by oss.sgi.com (8.14.3/8.14.3/SuSE Linux 0.8) with ESMTP id q16LRxZg166451 for ; Mon, 6 Feb 2012 15:27:59 -0600 X-ASG-Debug-ID: 1328563677-04bdf07516720290001-NocioJ Received: from ipmail05.adl6.internode.on.net (ipmail05.adl6.internode.on.net [150.101.137.143]) by cuda.sgi.com with ESMTP id fOGBbeWzoPtQCvh7; Mon, 06 Feb 2012 13:27:57 -0800 (PST) X-Barracuda-Envelope-From: david@fromorbit.com X-Barracuda-Apparent-Source-IP: 150.101.137.143 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlQEAG1FME95LD+bgWdsb2JhbABDr0QjAQEWJiWBcgEBBAE6HCMFCwgDDgouFCUDIROHfLhwE4shAgIJBQwHBgELAQgFAwMJBgQPBoQeAQMBBBgCBIJWYwSVJ4kwiUA Received: from ppp121-44-63-155.lns20.syd6.internode.on.net (HELO dastard) ([121.44.63.155]) by ipmail05.adl6.internode.on.net with ESMTP; 07 Feb 2012 07:57:56 +1030 Received: from dave by dastard with local (Exim 4.76) (envelope-from ) id 1RuW6M-0005B9-Lo; Tue, 07 Feb 2012 08:27:54 +1100 Date: Tue, 7 Feb 2012 08:27:54 +1100 From: Dave Chinner To: Jesper Juhl Cc: Raghavendra D Prabhu , xfs@oss.sgi.com, xfs-masters@oss.sgi.com, Ben Myers , Alex Elder , linux-kernel@vger.kernel.org Subject: Re: [PATCH][RFC] XFS: Fix mem leak and possible NULL deref in xfs_setattr_nonsize() Message-ID: <20120206212754.GC12836@dastard> X-ASG-Orig-Subj: Re: [PATCH][RFC] XFS: Fix mem leak and possible NULL deref in xfs_setattr_nonsize() References: <20120206091100.GA4350@Xye> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Barracuda-Connect: ipmail05.adl6.internode.on.net[150.101.137.143] X-Barracuda-Start-Time: 1328563677 X-Barracuda-URL: http://192.48.157.11:80/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using per-user scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=1.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.87806 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- On Mon, Feb 06, 2012 at 09:51:54PM +0100, Jesper Juhl wrote: > On Mon, 6 Feb 2012, Raghavendra D Prabhu wrote: > > As far as second one is concerned, looks fine, though this one should also do > > the same. > > > > diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c > > index ab30253..d331f5b 100644 > > --- a/fs/xfs/xfs_iops.c > > +++ b/fs/xfs/xfs_iops.c > > @@ -730,9 +730,9 @@ xfs_setattr_nonsize( > > return 0; > > > > out_trans_cancel: > > - xfs_trans_cancel(tp, 0); > > xfs_iunlock(ip, XFS_ILOCK_EXCL); > > out_dqrele: > > + xfs_trans_cancel(tp, 0); > > xfs_qm_dqrele(udqp); > > xfs_qm_dqrele(gdqp); > > return error; > > > > Thank you for the feedback. > > I worry about the fact that this suddenly calls xfs_trans_cancel() without > holding the lock. I don't know if that's actually significant though. You're right to worry about it, because it is significant. The transaction needs to be cancelled before we unlock the inode because the transaction cancel cleans up state on the inode if the inode has been joined to the transaction. Unlocking the inode before the transaction is cancelled means some other transaction can lock the inode and join it to a new transaction before the old one is cleaned up. Then Bad Stuff Happens. IOWs, the above change is not safe to make. > If it *is* significant, then I think the patch I just submitted in reply to > Dave Chinner is better since there we do the alloc and cancel before even > taking the lock at all in the leaky case and all other case have > identical behaviour as before. I'll go check it out. Cheers, Dave. -- Dave Chinner david@fromorbit.com