Commit 1aa77d1f authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

[AudioService] Initialize localtime functions when unsandboxed

crrev.com/790723 changed the unsandboxed audio process to use
the kNoSandbox sandbox type instead of the kAudio sandbox type
with sandboxing disabled.
While this behavior was correct, it causes crashes in some
MSAN builds due to lack of initialization of localtime functions,
which occurred when using the kAudio sandbox type.

This CL ensures that the audio process in Linux initializes
localtime functions when running unsandboxed.

Bug: 1109346
Change-Id: I97c1b7cc01906cb544305e47de8c59bf73a7c899
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341134Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796117}
parent ebd8d803
......@@ -6,6 +6,7 @@
#include <utility>
#include "base/command_line.h"
#include "base/no_destructor.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
......@@ -55,6 +56,11 @@ extern sandbox::TargetServices* g_utility_target_services;
#endif // defined(OS_WIN)
#endif // BUILDFLAG(ENABLE_LIBRARY_CDMS)
#if defined(OS_LINUX)
#include "sandbox/linux/services/libc_interceptor.h"
#include "sandbox/policy/sandbox_type.h"
#endif // defined(OS_LINUX)
namespace content {
namespace {
......@@ -150,6 +156,15 @@ auto RunAudio(mojo::PendingReceiver<audio::mojom::AudioService> receiver) {
<< "task_policy_set TASK_QOS_POLICY";
#endif
#if defined(OS_LINUX)
auto* command_line = base::CommandLine::ForCurrentProcess();
if (sandbox::policy::SandboxTypeFromCommandLine(*command_line) ==
sandbox::policy::SandboxType::kNoSandbox) {
// This is necessary to avoid crashes in certain environments.
// See https://crbug.com/1109346
sandbox::InitLibcLocaltimeFunctions();
}
#endif
return audio::CreateStandaloneService(std::move(receiver));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment