All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linas Vepstas <linasvepstas@gmail.com>
To: Eric Blake <eblake@redhat.com>
Cc: Mike Frysinger <vapier@gentoo.org>, Arnd Bergmann <arnd@arndb.de>,
	Paul Eggert <eggert@cs.ucla.edu>,
	Roland McGrath <roland@redhat.com>,
	Chris Metcalf <cmetcalf@tilera.com>,
	GLIBC Devel <libc-alpha@sourceware.org>,
	linux-kernel@vger.kernel.org, libc-ports@sourceware.org,
	linux-api@vger.kernel.org
Subject: Re: [BUG] Generic syscalls -- chmod vs. fchmodat
Date: Tue, 25 Jan 2011 16:10:48 -0600	[thread overview]
Message-ID: <AANLkTi=_sRM6k+fiKiOkbano7LCmys6Hy2Em_W3GaYx=@mail.gmail.com> (raw)
In-Reply-To: <4D3F4156.7010900@redhat.com>

Hi,

On 25 January 2011 15:32, Eric Blake <eblake@redhat.com> wrote:
>
> 7. fchmodat(AT_FDCWD, "") must fail with ENOENT.  Apparently, the kernel
> currently modifies ".", although point 1 says it might make more sense
> to fail with ENOENT so that glibc doesn't have to do as much work in
> chmod and fchmodat (if the kernel call does not change, then the burden
> is on glibc).

Interesting discussion, but I'm very embarrassed to say I started it
due to a mis-diagnosis of a bug :-(

In fact, the current kernels *do* check for an empty string, and do so
in order to maintain POSIX compliance, per Eric's points 5 and 7.
See fs/namei.c in do_getname, circa line 114,  where we read:

 * POSIX.1 2.4: an empty pathname is invalid (ENOENT).

This is backed up with code, circa line 129 ff:

   retval = strncpy_from_user(page, filename, len);
...
else if (!retval)
      retval = -ENOENT;
   return retval;

So an empty string will have length zero, and the ENOENT is indeed
set.

This handles cases 5 & 7.  I've no idea how any of the other cases
work out.

Note that getname() is used in a variety of places; its not just chmod,
but also in symlinks and many others.

--linas

  reply	other threads:[~2011-01-25 22:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24 19:57 [BUG] Generic syscalls -- chmod vs. fchmodat Linas Vepstas
2011-01-24 21:05 ` Roland McGrath
2011-01-24 21:32   ` Mike Frysinger
2011-01-25 14:29 ` Arnd Bergmann
2011-01-25 14:29   ` Arnd Bergmann
2011-01-25 17:45   ` Roland McGrath
2011-01-25 17:45     ` Roland McGrath
2011-01-25 18:21     ` Arnd Bergmann
2011-01-25 18:21       ` Arnd Bergmann
2011-01-25 18:34       ` Roland McGrath
2011-01-25 18:34         ` Roland McGrath
2011-01-25 20:04         ` Arnd Bergmann
2011-01-25 20:04           ` Arnd Bergmann
2011-01-25 18:52       ` Mike Frysinger
2011-01-25 18:52         ` Mike Frysinger
2011-01-25 19:56         ` Eric Blake
2011-01-25 19:56           ` Eric Blake
2011-01-25 20:31           ` Eric Blake
2011-01-25 20:31             ` Eric Blake
2011-01-25 21:32             ` Eric Blake
2011-01-25 21:32               ` Eric Blake
2011-01-25 22:10               ` Linas Vepstas [this message]
2011-02-10 18:12     ` Andries Brouwer
2011-02-10 18:17       ` Roland McGrath
2011-02-10 18:17         ` Roland McGrath
2011-02-11  9:11       ` Andreas Schwab

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='AANLkTi=_sRM6k+fiKiOkbano7LCmys6Hy2Em_W3GaYx=@mail.gmail.com' \
    --to=linasvepstas@gmail.com \
    --cc=arnd@arndb.de \
    --cc=cmetcalf@tilera.com \
    --cc=eblake@redhat.com \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-ports@sourceware.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=vapier@gentoo.org \
    /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.