From: Timothy Shimmin <tes@sgi.com>
To: Roger Willcocks <roger@filmlight.ltd.uk>
Cc: xfs@oss.sgi.com
Subject: Re: bug: truncate to zero + setuid
Date: Thu, 08 Nov 2007 14:13:22 +1100 [thread overview]
Message-ID: <47327ED2.8060402@sgi.com> (raw)
In-Reply-To: <000001c81f3e$eff344b0$6501a8c0@BODDINGTON>
Hi Roger,
Roger Willcocks wrote:
> Timothy Shimmin wrote:
>> Hi Roger,
>>
> ...
>> I don't like all these inconsistencies.
>
> Take a look at the attached patch relative to the current cvs (it's a
> bit big to put
> inline). The basic problem is it's currently unclear when to set the
> times from
> va_atime etc. and when to set them to the current time. So I've used the
> already
> defined XFS_AT_UPDxTIME flags to indicate that a time should be set to
> 'now'
> and XFS_AT_xTIME to mean set it using va_xtime. This seems to fit well with
> the current code and I wonder if that's how it was meant to work in the
> first
> place.
Yeah, I've looked at this a few times now ;-) and this _seems_ like
a reasonable thing to do to me.
So patch:
ATTR_ATIME_SET => XFS_AT_ATIME (& set va_atime etc) (used to set to given time)
ATTR_ATIME => XFS_AT_UPDATIME (used to set to "now")
likewise for M variant.
Previously:
ATTR_ATIME_SET => ATTR_UTIME flag (used to set given time)
must expect ATTR_ATIME to be set too to get va_atime
ATTR_ATIME => XFS_AT_ATIME (& set va_atime) (used to set to "now")
a bit confusing since it can store va_atime even if
ATTR_ATIME_SET is not on
> I've also removed the now redundant ATTR_UTIME flag and pulled
> the null truncate to the top, which simplifies things.
>
So these changes of:
if (mask & (XFS_AT_ATIME|XFS_AT_MTIME)) {
if (!file_owner) {
- if ((flags & ATTR_UTIME) &&
- !capable(CAP_FOWNER)) {
+ if (!capable(CAP_FOWNER)) {
Where you take out ATTR_UTIME make sense since XFS_AT_ATIME et al,
now refer to the case where a given time is provided
instead of requiring ATTR_UTIME to be set.
> One query: in both xfs_iops.c/xfs_vn_setattr and
> xfs_dm.c/xfs_dm_set_fileattr the
> ATIME branch sets the inode's atime directly.
xfs_vn_setattr()
if (ia_valid & ATTR_ATIME) {
vattr.va_mask |= XFS_AT_ATIME;
vattr.va_atime = attr->ia_atime;
inode->i_atime = attr->ia_atime;
}
xfs_dm_set_fileattr()
if (mask & DM_AT_ATIME) {
vat.va_mask |= XFS_AT_ATIME;
vat.va_atime.tv_sec = stat.fa_atime;
vat.va_atime.tv_nsec = 0;
inode->i_atime.tv_sec = stat.fa_atime;
}
Hmmm....
So this could change behavior for xfs_vn_setattr().
If previously we had ATTR_ATIME set but NOT ATTR_ATIME_SET,
then we would set inode->i_atime.
Now with the patch, in this case, we don't set inode->i_atime
at this point.
However, in this case we wouldn't want i_atime to be set to ia_atime
as we would want it to be set to "now" in xfs_ichgtime().
> This is probably something
> to do with
> the comment above xfs_iops.c/xfs_ichgtime ('to make sure the access time
> update
> will take') but it could probably be handled better.
>
I'll need to look.
>> BTW, your locking looks wrong - it appears you don't unlock when the
>> file is non-zero size.
>
> Oops...
>
I was also thinking of a read lock here.
And initializing quot vars to zero in variable definition at top.
This stuff really needs to be QA'ed well.
It would be too easy to get a regression in expected behavior.
Need to hunt out qa tests.
Thanks for the effort,
Tim.
prev parent reply other threads:[~2007-11-08 3:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-28 14:36 bug: truncate to zero + setuid Roger Willcocks
2007-10-29 0:54 ` Tim Shimmin
2007-10-29 18:56 ` Roger Willcocks
2007-10-30 4:06 ` Timothy Shimmin
2007-10-30 17:28 ` Roger Willcocks
2007-11-02 1:11 ` Timothy Shimmin
2007-11-04 11:59 ` Roger Willcocks
2007-11-08 3:13 ` Timothy Shimmin [this message]
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=47327ED2.8060402@sgi.com \
--to=tes@sgi.com \
--cc=roger@filmlight.ltd.uk \
--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