From: Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca>
To: linux-kernel@vger.kernel.org
Subject: How is pivot_root intended to be used?
Date: Mon, 01 Sep 2014 21:19:08 +0000 (GMT) [thread overview]
Message-ID: <fc0cb509956.5404e2cc@langara.bc.ca> (raw)
Hello,
I am not confused about how I can currently use pivot_root for
containers on my kernel (version 3.13). Currently a sequence like:
if (-1 == syscall(__NR_pivot_root, ".", ".")) {
perror("pivot_root");
return EXIT_FAILURE;
}
if (-1 == umount2(".", MNT_DETACH)) {
perror("umount");
return EXIT_FAILURE;
}
/* pivot_root() may or may not affect its current working
* directory. It is therefore recommended to call chdir("/")
* immediately after pivot_root().
*
* - http://man7.org/linux/man-pages/man2/pivot_root.2.html
*/
if (-1 == chdir("/")) {
perror("chdir");
return EXIT_FAILURE;
}
works. However, I am completely and totally confused about how the
pivot_root system call is intended to be used here and have absolutely
no idea if this will work in the future. This concerns me because I
don't want my program to potentially develop silent security bugs on
future versions of the Linux kernel.
Some information about the context. I am sandboxing a program just
after it has done a fork, unshared the mount namespace, setup a
sandbox directory and changed into it. If you just want to look at the
code, the actual code is avaliable at
https://gitorious.org/linted/linted/source/b25685ba4762bfb794c8f36ae74276d32d2b0ca8:src/spawn/spawn.c.
Thank you,
Steven Stewart-Gallus
next reply other threads:[~2014-09-01 21:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-01 21:19 Steven Stewart-Gallus [this message]
2014-09-02 19:53 ` How is pivot_root intended to be used? Andy Lutomirski
2014-09-04 7:35 ` Steven Stewart-Gallus
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=fc0cb509956.5404e2cc@langara.bc.ca \
--to=sstewartgallus00@mylangara.bc.ca \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox