diff --git a/security/sandbox/linux/Sandbox.cpp b/security/sandbox/linux/Sandbox.cpp index 79499d0e3837..fe6fc170ef36 100644 --- a/security/sandbox/linux/Sandbox.cpp +++ b/security/sandbox/linux/Sandbox.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -500,6 +501,14 @@ void SandboxEarlyInit() { } } +static void RunGlibcLazyInitializers() { + // Make glibc's lazy initialization of shm_open() run before sandboxing + int fd = shm_open("/dummy", O_RDONLY, 0); + if (fd > 0) { + close(fd); // In the unlikely case we actually opened something + } +} + static void SandboxLateInit() { #ifdef NIGHTLY_BUILD gSandboxCrashOnError = true; @@ -516,6 +525,8 @@ static void SandboxLateInit() { gSandboxCrashOnError = envVar[0] != '0'; } } + + RunGlibcLazyInitializers(); } // Common code for sandbox startup.