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

Side by Side Diff: content/zygote/zygote_main_linux.cc

Issue 1637083002: Add CdmService to keep track of CDMs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ContentDecryptionModule Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/zygote/zygote_main.h" 5 #include "content/zygote/zygote_main.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <openssl/rand.h> 9 #include <openssl/rand.h>
10 #include <pthread.h> 10 #include <pthread.h>
(...skipping 18 matching lines...) Expand all
29 #include "base/rand_util.h" 29 #include "base/rand_util.h"
30 #include "base/strings/safe_sprintf.h" 30 #include "base/strings/safe_sprintf.h"
31 #include "base/strings/string_number_conversions.h" 31 #include "base/strings/string_number_conversions.h"
32 #include "base/sys_info.h" 32 #include "base/sys_info.h"
33 #include "build/build_config.h" 33 #include "build/build_config.h"
34 #include "content/common/child_process_sandbox_support_impl_linux.h" 34 #include "content/common/child_process_sandbox_support_impl_linux.h"
35 #include "content/common/font_config_ipc_linux.h" 35 #include "content/common/font_config_ipc_linux.h"
36 #include "content/common/sandbox_linux/sandbox_debug_handling_linux.h" 36 #include "content/common/sandbox_linux/sandbox_debug_handling_linux.h"
37 #include "content/common/sandbox_linux/sandbox_linux.h" 37 #include "content/common/sandbox_linux/sandbox_linux.h"
38 #include "content/common/zygote_commands_linux.h" 38 #include "content/common/zygote_commands_linux.h"
39 #include "content/public/common/content_decryption_module_service.h"
39 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
40 #include "content/public/common/main_function_params.h" 41 #include "content/public/common/main_function_params.h"
41 #include "content/public/common/sandbox_linux.h" 42 #include "content/public/common/sandbox_linux.h"
42 #include "content/public/common/zygote_fork_delegate_linux.h" 43 #include "content/public/common/zygote_fork_delegate_linux.h"
43 #include "content/zygote/zygote_linux.h" 44 #include "content/zygote/zygote_linux.h"
44 #include "sandbox/linux/services/credentials.h" 45 #include "sandbox/linux/services/credentials.h"
45 #include "sandbox/linux/services/init_process_reaper.h" 46 #include "sandbox/linux/services/init_process_reaper.h"
46 #include "sandbox/linux/services/namespace_sandbox.h" 47 #include "sandbox/linux/services/namespace_sandbox.h"
47 #include "sandbox/linux/services/thread_helpers.h" 48 #include "sandbox/linux/services/thread_helpers.h"
48 #include "sandbox/linux/suid/client/setuid_sandbox_client.h" 49 #include "sandbox/linux/suid/client/setuid_sandbox_client.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 VLOG_IF(1, !library) << "Unable to load plugin " 312 VLOG_IF(1, !library) << "Unable to load plugin "
312 << plugins[i].path.value() << " " 313 << plugins[i].path.value() << " "
313 << error.ToString(); 314 << error.ToString();
314 315
315 (void)library; // Prevent release-mode warning. 316 (void)library; // Prevent release-mode warning.
316 } 317 }
317 } 318 }
318 } 319 }
319 #endif 320 #endif
320 321
322 // Loads any registered Content Decryption Modules but does not initialize
323 // them. This is needed by the zygote on Linux to get access to the modules
324 // before entering the sandbox.
325 void PreloadContentDecryptionModules() {
326 std::vector<std::pair<std::string, base::FilePath>> modules;
327
328 ContentDecryptionModuleService::GetInstance()->GetAllRegisteredModules(
329 &modules);
330 for (const auto& module : modules) {
331 const auto& module_library_path = module.second;
332 if (!module_library_path.empty()) {
333 base::NativeLibraryLoadError error;
334 base::NativeLibrary library =
335 base::LoadNativeLibrary(module_library_path, &error);
336 VLOG_IF(1, !library) << "Unable to load key system "
337 << module_library_path.value() << " "
338 << error.ToString();
339
340 (void)library; // Prevent release-mode warning.
341 }
342 }
343 }
344
321 // This function triggers the static and lazy construction of objects that need 345 // This function triggers the static and lazy construction of objects that need
322 // to be created before imposing the sandbox. 346 // to be created before imposing the sandbox.
323 static void ZygotePreSandboxInit() { 347 static void ZygotePreSandboxInit() {
324 base::RandUint64(); 348 base::RandUint64();
325 349
326 base::SysInfo::AmountOfPhysicalMemory(); 350 base::SysInfo::AmountOfPhysicalMemory();
327 base::SysInfo::MaxSharedMemorySize(); 351 base::SysInfo::MaxSharedMemorySize();
328 base::SysInfo::NumberOfProcessors(); 352 base::SysInfo::NumberOfProcessors();
329 353
330 // ICU DateFormat class (used in base/time_format.cc) needs to get the 354 // ICU DateFormat class (used in base/time_format.cc) needs to get the
331 // Olson timezone ID by accessing the zoneinfo files on disk. After 355 // Olson timezone ID by accessing the zoneinfo files on disk. After
332 // TimeZone::createDefault is called once here, the timezone ID is 356 // TimeZone::createDefault is called once here, the timezone ID is
333 // cached and there's no more need to access the file system. 357 // cached and there's no more need to access the file system.
334 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault()); 358 scoped_ptr<icu::TimeZone> zone(icu::TimeZone::createDefault());
335 359
336 // Pass BoringSSL a copy of the /dev/urandom file descriptor so RAND_bytes 360 // Pass BoringSSL a copy of the /dev/urandom file descriptor so RAND_bytes
337 // will work inside the sandbox. 361 // will work inside the sandbox.
338 RAND_set_urandom_fd(base::GetUrandomFD()); 362 RAND_set_urandom_fd(base::GetUrandomFD());
339 363
340 #if defined(ENABLE_PLUGINS) 364 #if defined(ENABLE_PLUGINS)
341 // Ensure access to the Pepper plugins before the sandbox is turned on. 365 // Ensure access to the Pepper plugins before the sandbox is turned on.
342 PreloadPepperPlugins(); 366 PreloadPepperPlugins();
343 #endif 367 #endif
344 #if defined(ENABLE_WEBRTC) 368 #if defined(ENABLE_WEBRTC)
345 InitializeWebRtcModule(); 369 InitializeWebRtcModule();
346 #endif 370 #endif
347 SkFontConfigInterface::SetGlobal( 371 SkFontConfigInterface::SetGlobal(
348 new FontConfigIPC(GetSandboxFD()))->unref(); 372 new FontConfigIPC(GetSandboxFD()))->unref();
373
374 // Ensure access to Content Decryption Modules before the sandbox is
375 // turned on.
376 PreloadContentDecryptionModules();
349 } 377 }
350 378
351 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) { 379 static bool CreateInitProcessReaper(base::Closure* post_fork_parent_callback) {
352 // The current process becomes init(1), this function returns from a 380 // The current process becomes init(1), this function returns from a
353 // newly created process. 381 // newly created process.
354 const bool init_created = 382 const bool init_created =
355 sandbox::CreateInitProcessReaper(post_fork_parent_callback); 383 sandbox::CreateInitProcessReaper(post_fork_parent_callback);
356 if (!init_created) { 384 if (!init_created) {
357 LOG(ERROR) << "Error creating an init process to reap zombies"; 385 LOG(ERROR) << "Error creating an init process to reap zombies";
358 return false; 386 return false;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS; 637 const bool namespace_sandbox_engaged = sandbox_flags & kSandboxLinuxUserNS;
610 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged); 638 CHECK_EQ(using_namespace_sandbox, namespace_sandbox_engaged);
611 639
612 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children, 640 Zygote zygote(sandbox_flags, std::move(fork_delegates), extra_children,
613 extra_fds); 641 extra_fds);
614 // This function call can return multiple times, once per fork(). 642 // This function call can return multiple times, once per fork().
615 return zygote.ProcessRequests(); 643 return zygote.ProcessRequests();
616 } 644 }
617 645
618 } // namespace content 646 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698