From: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
To: Rich Felker <dalias@aerifal.cx>
Cc: libc-alpha <libc-alpha@sourceware.org>, musl@lists.openwall.com
Subject: Re: O_EXEC and O_SEARCH
Date: Sat, 23 Feb 2013 00:01:39 -0500 [thread overview]
Message-ID: <CAHGf_=oa5gW_1511i6Wi4nTHHdiUaeLXucT+mr-76MFVqRm7rw@mail.gmail.com> (raw)
In-Reply-To: <20130223043336.GV20323@brightrain.aerifal.cx>
> 1. Try to open with O_RDONLY. If it succeeds, we're done. This is
> REALLY nice because it means O_SEARCH and O_EXEC "just work" even on
> ancient or broken kernels as long as the target file is readable.
Hmm..
This algorithm seems slightly strange to me. Why do you want to try O_RDONLY at
first?
O_RDONLY require read permission and O_SEARCH, if i understand correctly,
doesn't.
I think you should try O_PATH at first.
>
> 2. Else, add O_PATH and try again. If it still fails, we have a
> pre-2.6.39 kernel and there's nothing we can do, so just report
> failure.
>
> 3. If open succeeds with O_PATH, then if O_NOFOLLOW is also specified,
> check fstat, and close the file and report error if fstat succeeded
> and the obtained fd was a symbolic link.
>
> 4. If fstat failed, we have a buggy kernel, so either close and report
> an error, or just ignore the failure (possibly ignoring the
> requirements of O_NOFOLLOW), as there seems to be no way to handle it
> correctly on such kernels.
>
> If the kernel developers ever add O_SEARCH/O_EXEC at the kernel level
> with our proposed value of 3, a step 0, just passing the value to the
> kernel directly and seeing if it works, could also be added.
>
> Rich
next prev parent reply other threads:[~2013-02-23 5:01 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-22 0:45 Rich Felker
2013-02-23 3:05 ` KOSAKI Motohiro
2013-02-23 3:17 ` Rich Felker
2013-02-23 3:58 ` KOSAKI Motohiro
2013-02-23 4:33 ` Rich Felker
2013-02-23 5:01 ` KOSAKI Motohiro [this message]
2013-02-23 5:05 ` Rich Felker
2013-02-23 5:21 ` KOSAKI Motohiro
2013-02-23 4:54 ` KOSAKI Motohiro
2013-02-23 5:03 ` Rich Felker
2013-02-23 5:20 ` KOSAKI Motohiro
2013-02-23 5:28 ` KOSAKI Motohiro
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='CAHGf_=oa5gW_1511i6Wi4nTHHdiUaeLXucT+mr-76MFVqRm7rw@mail.gmail.com' \
--to=kosaki.motohiro@gmail.com \
--cc=dalias@aerifal.cx \
--cc=libc-alpha@sourceware.org \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).