From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Andy Lutomirski <luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
linux-man <linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH] open,linkat: Update AT_EMPTY_PATH and O_PATH documentation
Date: Fri, 09 May 2014 07:22:33 +0200 [thread overview]
Message-ID: <536C6619.1060608@gmail.com> (raw)
In-Reply-To: <CALCETrWc-=z8zd9=gy8Dt2r9x391Mu6BXTzzAwkCLrXxo6Erxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On 05/08/2014 10:34 PM, Andy Lutomirski wrote:
> On Thu, May 8, 2014 at 2:45 AM, Michael Kerrisk (man-pages)
> <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> On 08/09/2013 08:58 PM, Andy Lutomirski wrote:
>>> The current text reflects the general worry in the kernel about
>>> recipients of O_PATH fds being able to hardlink the referenced files.
>>> It turns out that it was possible to link these files regardless of
>>> any possible security concerns.
>>>
>>> Linux 3.11 removes the capability chech in AT_EMPTY_PATH. I expect
>>> that this functionality will be generally useful, so let's document it
>>> better.
>>
>> Andy,
>>
>> Again, long after the fact, sorry. But, I've applied this now (with
>> your spelling "chech" fixed in the change log, as you mentioned in the
>> follow-on mail).
>>
>> Nicely constructed patch by the way: I liked the way that the additions
>> to the linkat() text explained why capability check (and thus the man
>> page text describing the need for that check) was removed.
>
> Thanks. Unfortunately, this was reverted in
> f0cc6ffb8ce8961db587e5072168cac0cbc25f05 due to never-quite-explained
> security issues. :(
Ahhh--okay. But still, some parts of your patch are useful, are they not? I mean:
+This will
+generally not work if the file has a link count of zero (files
+created with
+.BR O_TMPFILE
+and without
+.BR O_EXCL
+are an exception).
and
+If procfs is mounted,
+this can be used as an alternative to AT_EMPTY_PATH,
are still correct, right?
I've tweaked the relevant parts of link(2). Do the following pieces now look
okay to you:
AT_EMPTY_PATH (since Linux 2.6.39)
If oldpath is an empty string, create a link to the file
referenced by olddirfd (which may have been obtained
using the open(2) O_PATH flag). In this case, olddirfd
can refer to any type of file, not just a directory.
This will generally not work if the file has a link
count of zero (files created with O_TMPFILE and without
O_EXCL are an exception). The caller must have the
CAP_DAC_READ_SEARCH capability in order to use this
flag. This flag is Linux-specific; define _GNU_SOURCE
to obtain its definition.
AT_SYMLINK_FOLLOW (since Linux 2.6.18)
By default, linkat(), does not dereference oldpath if it
is a symbolic link (like link()). The flag AT_SYM‐
LINK_FOLLOW can be specified in flags to cause oldpath
to be dereferenced if it is a symbolic link. If procfs
is mounted, this can be used as an alternative to
AT_EMPTY_PATH, like this:
linkat(AT_FDCWD, "/proc/self/fd/<fd>", newdirfd,
newname, AT_SYMLINK_FOLLOW);
?
Cheers,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2014-05-09 5:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-09 18:58 [PATCH] open,linkat: Update AT_EMPTY_PATH and O_PATH documentation Andy Lutomirski
[not found] ` <818bf4803d4c8d20fa78a485bc57f8240a4f89b8.1376074657.git.luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.org>
2013-08-09 18:59 ` Andy Lutomirski
2014-05-08 9:45 ` Michael Kerrisk (man-pages)
[not found] ` <536B522A.9050906-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-08 20:34 ` Andy Lutomirski
[not found] ` <CALCETrWc-=z8zd9=gy8Dt2r9x391Mu6BXTzzAwkCLrXxo6Erxw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-09 5:22 ` Michael Kerrisk (man-pages) [this message]
[not found] ` <536C6619.1060608-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-10 0:59 ` Andy Lutomirski
[not found] ` <CALCETrXdXXeAVNmOu7wrUZpMbKdRo0cgn5S6AtgAEotf+v1nYw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-10 17:45 ` Michael Kerrisk (man-pages)
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=536C6619.1060608@gmail.com \
--to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=luto-kltTT9wpgjJwATOyAt5JVQ@public.gmane.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.