linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael Kerrisk" <mtk.manpages@googlemail.com>
To: "Miklos Szeredi" <miklos@szeredi.hu>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	hch@lst.de, viro@zeniv.linux.org.uk, jamie@shareable.org,
	drepper@redhat.com, linux-fsdevel@vger.kernel.org,
	subrata@linux.vnet.ibm.com
Subject: Re: [parch 3/4] vfs: utimensat(): fix error checking for {UTIME_NOW,UTIME_OMIT} case
Date: Wed, 4 Jun 2008 11:27:18 +0200	[thread overview]
Message-ID: <cfd18e0f0806040227h448f146ap7754c194b50dadb8@mail.gmail.com> (raw)
In-Reply-To: <E1K3lIS-0007lg-4e@pomaz-ex.szeredi.hu>

On Wed, Jun 4, 2008 at 7:12 AM, Miklos Szeredi <miklos@szeredi.hu> wrote:
>> > Miklos suggested an alternative idea, migrating the
>> > is_owner_or_cap() checks into fs/attr.c:inode_change_ok() via
>> > the use of an ATTR_OWNER_CHECK flag.  Maybe we could do that
>> > later, but for now I've gone with this version, which is
>> > simpler, and can be more easily read as being correct.
>>
>> Wise decision.
>
> Or maybe not.  Isn't this a simpler and more readable patch?

The idea is okay (we talked about it already), but I don't like doing
it now because it only migrates *one* of the is_owner_or_cap() checks
out of do_utimes().  We could revisit this later in the context of
migrating both checks out of do_utimes(), but I'd prefer to leave that
for now.

> Index: linux/fs/attr.c
> ===================================================================
> --- linux.orig/fs/attr.c        2008-06-03 13:10:11.000000000 +0200
> +++ linux/fs/attr.c     2008-06-04 07:07:23.000000000 +0200
> @@ -51,7 +51,7 @@ int inode_change_ok(struct inode *inode,
>        }
>
>        /* Check for setting the inode time. */
> -       if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET)) {
> +       if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_UPDATE_TIMES)) {
>                if (!is_owner_or_cap(inode))
>                        goto error;
>        }
> Index: linux/fs/utimes.c
> ===================================================================
> --- linux.orig/fs/utimes.c      2008-06-03 13:10:11.000000000 +0200
> +++ linux/fs/utimes.c   2008-06-04 07:10:53.000000000 +0200
> @@ -102,9 +102,14 @@ long do_utimes(int dfd, char __user *fil
>        if (error)
>                goto dput_and_out;
>
> -       /* Don't worry, the checks are done in inode_change_ok() */
>        newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME;
>        if (times) {
> +               /*
> +                * Checking the owner is done in inode_change_ok(),
> +                * even for the special UTIME_OMIT/UTIME_NOW cases.
> +                */
> +               newattrs.ia_valid |= ATTR_UPDATE_TIMES
> +
>                error = -EPERM;
>                 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
>                        goto mnt_drop_write_and_out;
> Index: linux/include/linux/fs.h
> ===================================================================
> --- linux.orig/include/linux/fs.h       2008-06-03 13:10:25.000000000 +0200
> +++ linux/include/linux/fs.h    2008-06-04 07:07:43.000000000 +0200
> @@ -333,6 +333,7 @@ typedef void (dio_iodone_t)(struct kiocb
>  #define ATTR_FILE      8192
>  #define ATTR_KILL_PRIV 16384
>  #define ATTR_OPEN      32768   /* Truncating from open(O_TRUNC) */
> +#define ATTR_UPDATE_TIMES      (1 << 16)
>
>  /*
>  * This is the Inode Attributes structure, used for notify_change().  It
>



-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Found a bug? http://www.kernel.org/doc/man-pages/reporting_bugs.html

  reply	other threads:[~2008-06-04  9:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-03 22:25 [parch 3/4] vfs: utimensat(): fix error checking for {UTIME_NOW,UTIME_OMIT} case Michael Kerrisk
2008-06-04  4:37 ` Miklos Szeredi
2008-06-04  4:54   ` Miklos Szeredi
2008-06-04  5:12   ` Miklos Szeredi
2008-06-04  9:27     ` Michael Kerrisk [this message]
2008-06-04  9:28   ` Michael Kerrisk

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=cfd18e0f0806040227h448f146ap7754c194b50dadb8@mail.gmail.com \
    --to=mtk.manpages@googlemail.com \
    --cc=akpm@linux-foundation.org \
    --cc=drepper@redhat.com \
    --cc=hch@lst.de \
    --cc=jamie@shareable.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=subrata@linux.vnet.ibm.com \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).