From: Andrew Morton <akpm@linux-foundation.org>
To: Bernd Petrovitsch <bernd@firmix.at>
Cc: linux-kernel@vger.kernel.org, Alexey Dobriyan <adobriyan@gmail.com>
Subject: Re: O_NOATIME and files in /proc
Date: Fri, 20 Nov 2009 13:36:51 -0800 [thread overview]
Message-ID: <20091120133651.9df2da80.akpm@linux-foundation.org> (raw)
In-Reply-To: <1258477590.16246.35.camel@tara.firmix.at>
On Tue, 17 Nov 2009 18:06:29 +0100
Bernd Petrovitsch <bernd@firmix.at> wrote:
> Hi all!
>
> Is there a specific reason that open can not open files (at
> least /proc/noatime and /proc/cpuinfo) under /proc with NO_ATIME as the
> following program shows:
> ---- snip ----
> {12}cat noatime.c
>
> #define _GNU_SOURCE
> #include <stdio.h>
> #include <string.h>
> #include <errno.h>
> #include <fcntl.h>
>
> int main(void)
> {
> int fd = open("/proc/uptime", O_RDONLY|O_NOATIME);
> if (fd == -1) {
> printf("fd=%d, errno=%s\n", fd, strerror(errno));
> } else {
> printf("fd=%d\n", fd);
> }
> return 0;
> }
> ---- snip ----
> When I compile and run it, it prints
> ---- snip ----
> {13}./noatime
> fd=-1, errno=Operation not permitted
> ---- snip ----
> Removing the "NO_ATIME" makes it work (of course).
>
> I can also set the "noatime" mount flag on a remount and it shows up
> in /proc/mounts but it makes for the above no difference.
>
I guess you're hitting the check in may_open():
/* O_NOATIME can only be set by the owner or superuser */
if (flag & O_NOATIME)
if (!is_owner_or_cap(inode)) {
error = -EPERM;
goto err_out;
}
This code was added in 2004 and neither the changelog nor the code
comment explain _why_ this was done (bad). It might be recorded in the
contemporary email discussion.
I assume it was done this way under the assumption that people might
want to use atime to determine if other users have been peeking at
their junk. Avoid permitting junk-peekers to conceal their tracks.
next prev parent reply other threads:[~2009-11-20 21:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-17 17:06 O_NOATIME and files in /proc Bernd Petrovitsch
2009-11-20 21:36 ` Andrew Morton [this message]
2009-11-20 22:11 ` Alan Cox
2009-11-30 10:36 ` Bernd Petrovitsch
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=20091120133651.9df2da80.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=adobriyan@gmail.com \
--cc=bernd@firmix.at \
--cc=linux-kernel@vger.kernel.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.