From: Dave Chinner <david@fromorbit.com>
To: Jesper Juhl <jj@chaosbits.net>
Cc: Alex Elder <elder@kernel.org>,
linux-kernel@vger.kernel.org, xfs@oss.sgi.com,
xfs-masters@oss.sgi.com, Ben Myers <bpm@sgi.com>,
Raghavendra D Prabhu <raghu.prabhu13@gmail.com>
Subject: Re: [PATCH][RFC] XFS: Fix mem leak and possible NULL deref in xfs_setattr_nonsize()
Date: Tue, 7 Feb 2012 08:27:54 +1100 [thread overview]
Message-ID: <20120206212754.GC12836@dastard> (raw)
In-Reply-To: <alpine.LNX.2.00.1202062145240.20117@swampdragon.chaosbits.net>
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
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-02-06 21:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-05 21:23 [PATCH][RFC] XFS: Fix mem leak and possible NULL deref in xfs_setattr_nonsize() Jesper Juhl
2012-02-06 6:23 ` Dave Chinner
2012-02-06 20:44 ` Jesper Juhl
2012-07-20 19:28 ` Jesper Juhl
2012-02-06 9:11 ` Raghavendra D Prabhu
2012-02-06 20:51 ` Jesper Juhl
2012-02-06 21:27 ` Dave Chinner [this message]
2012-02-07 22:41 ` Raghavendra D Prabhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120206212754.GC12836@dastard \
--to=david@fromorbit.com \
--cc=bpm@sgi.com \
--cc=elder@kernel.org \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=raghu.prabhu13@gmail.com \
--cc=xfs-masters@oss.sgi.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox