OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/nacl/browser/nacl_browser.h" | 5 #include "components/nacl/browser/nacl_browser.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 109 } |
110 | 110 |
111 // Crash throttling parameters. | 111 // Crash throttling parameters. |
112 const size_t kMaxCrashesPerInterval = 3; | 112 const size_t kMaxCrashesPerInterval = 3; |
113 const int64 kCrashesIntervalInSeconds = 120; | 113 const int64 kCrashesIntervalInSeconds = 120; |
114 | 114 |
115 } // namespace | 115 } // namespace |
116 | 116 |
117 namespace nacl { | 117 namespace nacl { |
118 | 118 |
119 base::File OpenNaClExecutableImpl(const base::FilePath& file_path) { | 119 base::File OpenNaClReadExecImpl(const base::FilePath& file_path, |
| 120 bool is_executable) { |
120 // Get a file descriptor. On Windows, we need 'GENERIC_EXECUTE' in order to | 121 // Get a file descriptor. On Windows, we need 'GENERIC_EXECUTE' in order to |
121 // memory map the executable. | 122 // memory map the executable. |
122 // IMPORTANT: This file descriptor must not have write access - that could | 123 // IMPORTANT: This file descriptor must not have write access - that could |
123 // allow a NaCl inner sandbox escape. | 124 // allow a NaCl inner sandbox escape. |
124 base::File file(file_path, | 125 |
125 (base::File::FLAG_OPEN | | 126 base::File file(file_path, is_executable |
126 base::File::FLAG_READ | | 127 ? base::File::FLAG_OPEN | |
127 base::File::FLAG_EXECUTE)); // Windows only flag. | 128 base::File::FLAG_READ | |
| 129 base::File::FLAG_EXECUTE // Windows only flag |
| 130 : base::File::FLAG_OPEN | |
| 131 base::File::FLAG_READ); |
128 if (!file.IsValid()) | 132 if (!file.IsValid()) |
129 return file.Pass(); | 133 return file.Pass(); |
130 | 134 |
131 // Check that the file does not reference a directory. Returning a descriptor | 135 // Check that the file does not reference a directory. Returning a descriptor |
132 // to an extension directory could allow an outer sandbox escape. openat(...) | 136 // to a directory could allow an outer sandbox escape. openat(...) |
133 // could be used to traverse into the file system. | 137 // could be used to traverse into the file system. |
134 base::File::Info file_info; | 138 base::File::Info file_info; |
135 if (!file.GetInfo(&file_info) || file_info.is_directory) | 139 if (!file.GetInfo(&file_info) || file_info.is_directory) |
136 return base::File(); | 140 return base::File(); |
137 | 141 |
138 return file.Pass(); | 142 return file.Pass(); |
139 } | 143 } |
140 | 144 |
141 NaClBrowser::NaClBrowser() | 145 NaClBrowser::NaClBrowser() |
142 : weak_factory_(this), | 146 : weak_factory_(this), |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
549 bool NaClBrowser::IsThrottled() { | 553 bool NaClBrowser::IsThrottled() { |
550 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 554 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
551 if (crash_times_.size() != kMaxCrashesPerInterval) { | 555 if (crash_times_.size() != kMaxCrashesPerInterval) { |
552 return false; | 556 return false; |
553 } | 557 } |
554 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); | 558 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); |
555 return delta.InSeconds() <= kCrashesIntervalInSeconds; | 559 return delta.InSeconds() <= kCrashesIntervalInSeconds; |
556 } | 560 } |
557 | 561 |
558 } // namespace nacl | 562 } // namespace nacl |
OLD | NEW |