xfs
[Top] [All Lists]

Re: [PATCH v4 6/7] xfs: check that eofblocks ioctl caller can write matc

To: Dwight Engen <dwight.engen@xxxxxxxxxx>
Subject: Re: [PATCH v4 6/7] xfs: check that eofblocks ioctl caller can write matched inodes
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 24 Jul 2013 13:46:15 +1000
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20130722120007.2a82cea5@xxxxxxxxxx>
References: <20130717114746.4e133042@xxxxxxxxxx> <20130719060221.GX11674@dastard> <20130722120007.2a82cea5@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Mon, Jul 22, 2013 at 12:00:07PM -0400, Dwight Engen wrote:
> On Fri, 19 Jul 2013 16:02:21 +1000
> Dave Chinner <david@xxxxxxxxxxxxx> wrote:
> 
> [...]
> > > diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c
> > > index d873ab9e..728283a 100644
> > > --- a/fs/xfs/xfs_icache.c
> > > +++ b/fs/xfs/xfs_icache.c
> > > @@ -1247,6 +1247,10 @@ xfs_inode_free_eofblocks(
> > >           if (!xfs_inode_match_id(ip, eofb))
> > >                   return 0;
> > >  
> > > +         if (eofb->eof_flags & XFS_EOF_FLAGS_PERM_CHECK &&
> > > +             inode_permission(VFS_I(ip), MAY_WRITE))
> > > +                 return 0;
> > 
> > This assumes we are walking fully instantiated VFS inodes. That's
> > not necessarily true - we may be walking inodes that have already
> > been dropped from the VFS and are waiting for background reclaim to
> 
> Hi Dave, in looking at this a bit I don't see how they can be dropped
> from the VFS since they are igrab()ed in the flow:
> 
> xfs_icache_free_eofblocks
>   xfs_inode_ag_iterator_tag
>     xfs_inode_ag_walk
>       xfs_inode_ag_walk_grab
>         igrab

Ah, right, I forgot that we have two different methods of walking
that tree, and the one that xfs_icache_free_eofblocks() avoids
inodes in reclaim.

> and I don't see a way for xfs_inode_free_eofblocks() to be called other
> than the ag_walk flow.
> 
> If there is a way to get into xfs_inode_free_eofblocks where we can't
> use VFS_I(ip) then it will be a problem for the new code in
> xfs_inode_match_id() as well.

We can always use VFS_I(ip) because the struct inode is embedded in
the struct xfs_inode, so that's never an issue.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>