| Index: sandbox/linux/services/credentials.cc
|
| diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc
|
| index ed21fd192bd0c7eda1ffaadcbf6583c26f18751d..c8c679d8515e16db91e2636315f3974747b5066a 100644
|
| --- a/sandbox/linux/services/credentials.cc
|
| +++ b/sandbox/linux/services/credentials.cc
|
| @@ -23,7 +23,9 @@
|
| #include "base/template_util.h"
|
| #include "base/third_party/valgrind/valgrind.h"
|
| #include "sandbox/linux/services/namespace_utils.h"
|
| +#include "sandbox/linux/services/proc_util.h"
|
| #include "sandbox/linux/services/syscall_wrappers.h"
|
| +#include "sandbox/linux/services/thread_helpers.h"
|
|
|
| namespace sandbox {
|
|
|
| @@ -129,7 +131,10 @@ void CheckCloneNewUserErrno(int error) {
|
|
|
| } // namespace.
|
|
|
| -bool Credentials::DropAllCapabilities() {
|
| +bool Credentials::DropAllCapabilities(int proc_fd) {
|
| + DCHECK_LE(0, proc_fd);
|
| + CHECK(ThreadHelpers::IsSingleThreaded(proc_fd));
|
| +
|
| ScopedCap cap(cap_init());
|
| CHECK(cap);
|
| PCHECK(0 == cap_set_proc(cap.get()));
|
| @@ -138,6 +143,11 @@ bool Credentials::DropAllCapabilities() {
|
| return true;
|
| }
|
|
|
| +bool Credentials::DropAllCapabilities() {
|
| + base::ScopedFD proc_fd(ProcUtil::OpenProc());
|
| + return Credentials::DropAllCapabilities(proc_fd.get());
|
| +}
|
| +
|
| bool Credentials::HasAnyCapability() {
|
| ScopedCap current_cap(cap_get_proc());
|
| CHECK(current_cap);
|
| @@ -220,9 +230,12 @@ bool Credentials::MoveToNewUserNS() {
|
| return true;
|
| }
|
|
|
| -bool Credentials::DropFileSystemAccess() {
|
| +bool Credentials::DropFileSystemAccess(int proc_fd) {
|
| + CHECK_LE(0, proc_fd);
|
| +
|
| CHECK(ChrootToSafeEmptyDir());
|
| CHECK(!base::DirectoryExists(base::FilePath("/proc")));
|
| + CHECK(!ProcUtil::HasOpenDirectory(proc_fd));
|
| // We never let this function fail.
|
| return true;
|
| }
|
|
|