From: Timothy Shimmin <tes@sgi.com>
To: Jeff Layton <jlayton@redhat.com>
Cc: Josef Sipek <jsipek@fsl.cs.sunysb.edu>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH 2/4] Fix mainline filesystems to handle ATTR_KILL_ bits correctly
Date: Tue, 28 Aug 2007 11:37:52 +1000 [thread overview]
Message-ID: <46D37C70.5070907@sgi.com> (raw)
In-Reply-To: <20070821182305.7c0cb135.jlayton@redhat.com>
Jeff Layton wrote:
> On Tue, 21 Aug 2007 17:21:28 -0400
> Josef Sipek <jsipek@fsl.cs.sunysb.edu> wrote:
>
>> On Tue, Aug 21, 2007 at 07:35:51AM -0400, Jeff Layton wrote:
>>> On Tue, 21 Aug 2007 15:35:08 +1000
>>> Timothy Shimmin <tes@sgi.com> wrote:
>>>
>>>> Jeff Layton wrote:
>>>>> This should fix all of the filesystems in the mainline kernels to handle
>>>>> ATTR_KILL_SUID and ATTR_KILL_SGID correctly. For most of them, this is
>>>>> just a matter of making sure that they call generic_attrkill early in
>>>>> the setattr inode op.
>>>>>
>>>>> Signed-off-by: Jeff Layton <jlayton@redhat.com>
>>>>> ---
>>>>> fs/xfs/linux-2.6/xfs_iops.c | 5 ++++-
>>>>> --- a/fs/xfs/linux-2.6/xfs_iops.c
>>>>> +++ b/fs/xfs/linux-2.6/xfs_iops.c
>>>>> @@ -651,12 +651,15 @@ xfs_vn_setattr(
>>>>> struct iattr *attr)
>>>>> {
>>>>> struct inode *inode = dentry->d_inode;
>>>>> - unsigned int ia_valid = attr->ia_valid;
>>>>> + unsigned int ia_valid;
>>>>> bhv_vnode_t *vp = vn_from_inode(inode);
>>>>> bhv_vattr_t vattr = { 0 };
>>>>> int flags = 0;
>>>>> int error;
>>>>>
>>>>> + generic_attrkill(inode->i_mode, attr);
>>>>> + ia_valid = attr->ia_valid;
>>>>> +
>>>>> if (ia_valid & ATTR_UID) {
>>>>> vattr.va_mask |= XFS_AT_UID;
>>>>> vattr.va_uid = attr->ia_uid;
>>>> Looks reasonable to me for XFS.
>>>> Acked-by: Tim Shimmin <tes@sgi.com>
>>>>
>>>> So before, this clearing would happen directly in notify_change()
>>>> and now this won't happen until notify_change() calls i_op->setattr
>>>> which for a particular fs it can call generic_attrkill() to do it.
>>>> So I guess for the cases where i_op->setattr is called outside of
>>>> via notify_change, we don't normally have ATTR_KILL_SUID/SGID
>>>> set so that nothing will happen there?
>>> Right. If neither ATTR_KILL bit is set then generic_attrkill is a
>>> noop.
>>>
>>>> I guess just wondering the effect with having the code on all
>>>> setattr's. (I'm not familiar with the code path)
>>>>
>>> These bits are referenced in very few places in the current kernel
>>> tree -- mostly in the VFS layer. The *only* place I see that they
>>> actually get interpreted into a mode change is in notify_change. So
>>> places that call setattr ops w/o going through notify_change are
>>> not likely to have those bits set.
>>>
>>> But hypothetically, if a fs did set ATTR_KILL_* and call setattr
>>> directly, then the setattr would now include a mode change that
>>> clears setuid or setgid bits where it may not have before.
>
> I should probably clarify -- in the hypothetical situation above,
> the setattr function would have to call generic_attrkill (as most
> filesystems should do with this change).
>
Thanks for the confirmation. That's what it looked like to me
but I wanted to know explicitly what the thinking was.
>> It almost sounds like an argument for a new inode op (NULL would use
>> generic_attr_kill).
>>
>
> That's not a bad idea at all. I suppose that would be easier than
> modifying every fs like this, and it does seem like it might be
> cleaner. I need to mull it over, but that might be the best
> solution.
>
Yeah, sounds a much more direct way of handling things and as you
say wouldn't need most of the filesystems to all be modified calling
generic_attrkill.
Not sure what the ramifications of adding a new iop are though.
Cheers,
Tim.
next prev parent reply other threads:[~2007-08-28 1:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-20 20:53 [PATCH 2/4] Fix mainline filesystems to handle ATTR_KILL_ bits correctly Jeff Layton
2007-08-20 21:07 ` [Jfs-discussion] " Dave Kleikamp
2007-08-21 5:35 ` Timothy Shimmin
2007-08-21 11:35 ` Jeff Layton
2007-08-21 21:21 ` Josef Sipek
2007-08-21 22:23 ` Jeff Layton
2007-08-28 1:37 ` Timothy Shimmin [this message]
2007-08-21 15:04 ` Jan Harkes
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=46D37C70.5070907@sgi.com \
--to=tes@sgi.com \
--cc=jlayton@redhat.com \
--cc=jsipek@fsl.cs.sunysb.edu \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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