All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: ebb9@byu.net
Cc: bugzilla-daemon@bugzilla.kernel.org,
	bugme-daemon@bugzilla.kernel.org,
	Ulrich Drepper <drepper@redhat.com>,
	Alexey Dobriyan <adobriyan@gmail.com>,
	Michael Kerrisk <mtk.manpages@googlemail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [Bugme-new] [Bug 14832] New: futimens (AT_FDCWD, arg) should fail
Date: Tue, 22 Dec 2009 14:31:37 -0800	[thread overview]
Message-ID: <20091222143137.7f9b4e8b.akpm@linux-foundation.org> (raw)
In-Reply-To: <bug-14832-10286@http.bugzilla.kernel.org/>


(switched to email.  Please respond via emailed reply-to-all, not via the
bugzilla web interface).

On Fri, 18 Dec 2009 16:08:29 GMT
bugzilla-daemon@bugzilla.kernel.org wrote:

> http://bugzilla.kernel.org/show_bug.cgi?id=14832
> 
>            Summary: futimens (AT_FDCWD, arg) should fail
>            Product: File System
>            Version: 2.5
>           Platform: All
>         OS/Version: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: Other
>         AssignedTo: fs_other@kernel-bugs.osdl.org
>         ReportedBy: ebb9@byu.net
>         Regression: No
> 
> 
> According to POSIX 2008, futimens() shall fail with EBADF if fd is not a valid
> file descriptor.  AT_FDCWD, being negative, falls into this category.  Yet this
> program mistakenly changes the timestamps of the current directory, then
> aborts:
> 
> #include <sys/stat.h>
> #include <fcntl.h>
> #include <errno.h>
> #include <stdlib.h>
> int
> main ()
> {
>   if (futimens (AT_FDCWD, NULL) != -1 || errno != EBADF)
>     abort ();
> }
> 
> Since futimens is a library call on top of utimensat, the fix is to add a
> special case to the utimensat syscall that fails with EBADF if fd is negative
> when path is NULL.
> 

Confused.

: long do_utimes(int dfd, char __user *filename, struct timespec *times, int flags)
: {
: 	int error = -EINVAL;
: 
: 	if (times && (!nsec_valid(times[0].tv_nsec) ||
: 		      !nsec_valid(times[1].tv_nsec))) {
: 		goto out;
: 	}
: 
: 	if (flags & ~AT_SYMLINK_NOFOLLOW)
: 		goto out;
: 
: 	if (filename == NULL && dfd != AT_FDCWD) {
: 		struct file *file;
: 
: 		if (flags & AT_SYMLINK_NOFOLLOW)
: 			goto out;
: 
: 		file = fget(dfd);
: 		error = -EBADF;
: 		if (!file)
: 			goto out;
: 

afacit, if filename==NULL and dfd==-1 then fget() will return NULL and
the syscall returns -EBAFD.

Your report doesn't tell us what kernel version you're testing.  We did
fix a few things ni this area, but it was a long time ago.


       reply	other threads:[~2009-12-22 22:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-14832-10286@http.bugzilla.kernel.org/>
2009-12-22 22:31 ` Andrew Morton [this message]
2009-12-23 13:08   ` [Bugme-new] [Bug 14832] New: futimens (AT_FDCWD, arg) should fail Eric Blake
2009-12-24 11:03     ` OGAWA Hirofumi

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=20091222143137.7f9b4e8b.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=adobriyan@gmail.com \
    --cc=bugme-daemon@bugzilla.kernel.org \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=drepper@redhat.com \
    --cc=ebb9@byu.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtk.manpages@googlemail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.