Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Unified Diff: sandbox/linux/seccomp-bpf/util.cc

Issue 12223109: SECCOMP-BPF: Refactor the BPF sandbox API to use fewer "static" fields and methods. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make sure unnamed namespaces are always top-level Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/seccomp-bpf/util.cc
diff --git a/sandbox/linux/seccomp-bpf/util.cc b/sandbox/linux/seccomp-bpf/util.cc
index 77a92d9091439127c2fce90dcaea98ef937a1da7..e84e1900dc5a5bcb865338f4a04e3057f3855c06 100644
--- a/sandbox/linux/seccomp-bpf/util.cc
+++ b/sandbox/linux/seccomp-bpf/util.cc
@@ -115,10 +115,12 @@ bool Util::GetFds(int transport, void *buf, size_t *len, ...) {
return true;
}
-void Util::CloseAllBut(int fd, ...) {
- int proc_fd;
+void Util::CloseAllBut(int proc_fd, int fd, ...) {
int fdir;
- if ((proc_fd = Sandbox::proc_fd()) < 0 ||
+ if (proc_fd < 0) {
+ proc_fd = open("/proc/", O_RDONLY|O_DIRECTORY);
jln (very slow on Chromium) 2013/02/20 01:35:49 It really scares me to do that. We absolutely don'
+ }
+ if (proc_fd < 0 ||
(fdir = openat(proc_fd, "self/fd", O_RDONLY|O_DIRECTORY)) < 0) {
SANDBOX_DIE("Cannot access \"/proc/self/fd\"");
}

Powered by Google App Engine
This is Rietveld 408576698