From 8692675af1422bd7728fde2f5cfba20cb3bfee56 Mon Sep 17 00:00:00 2001 From: Jed Davis Date: Wed, 14 Aug 2019 22:48:33 +0000 Subject: [PATCH] Bug 1479960 - Fix the main thread I/O tests to handle the IPC shared memory changes. r=florian The tests for unexpected main thread I/O had exemptions for the specific paths that were being used for shared memory, which would cause it to fail with the changes in this bug. This patch does two things: 1. On Linux, /dev/shm is always tmpfs (a memory filesystem), so it's not going to cause disk I/O, and it's used by glibc to implement the POSIX standard shm_open API. This allows all /dev/shm paths instead of limiting it to a hard-coded prefix. 2. On MacOS, with the patches in this bug, we'll no longer use temporary files for shared memory on current OS versions, but we still need them on older versions to avoid an OS bug (https://crbug.com/project-zero/1671), and they are backed by disk in this case, so we want to allow only the IPC files. However, the path prefix has changed. Differential Revision: https://phabricator.services.mozilla.com/D34628 --HG-- extra : moz-landing-system : lando --- .../browser_startup_content_mainthreadio.js | 28 +++++++++++++------ .../browser_startup_mainthreadio.js | 28 +++++++++++++------ 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/browser/base/content/test/performance/browser_startup_content_mainthreadio.js b/browser/base/content/test/performance/browser_startup_content_mainthreadio.js index 0136cb428f34..5d03db0156b2 100644 --- a/browser/base/content/test/performance/browser_startup_content_mainthreadio.js +++ b/browser/base/content/test/performance/browser_startup_content_mainthreadio.js @@ -291,7 +291,7 @@ add_task(async function() { }); } - let tmpPath = expandWhitelistPath(MAC ? "TmpD:" : "/dev/shm").toLowerCase(); + let tmpPath = expandWhitelistPath("TmpD:").toLowerCase(); let shouldPass = true; for (let procName in processes) { let whitelist = processes[procName]; @@ -345,15 +345,25 @@ add_task(async function() { continue; } - if (!WIN) { - if (filename == "/dev/urandom") { - continue; - } + if (!WIN && filename == "/dev/urandom") { + continue; + } - // Ignore I/O due to IPC. This doesn't really touch the disk. - if (filename.startsWith(tmpPath + "/org.chromium.")) { - continue; - } + // /dev/shm is always tmpfs (a memory filesystem); this isn't + // really I/O any more than mmap/munmap are. + if (LINUX && filename.startsWith("/dev/shm/")) { + continue; + } + + // Shared memory uses temporary files on MacOS <= 10.11 to avoid + // a kernel security bug that will never be patched (see + // https://crbug.com/project-zero/1671 for details). This can + // be removed when we no longer support those OS versions. + // + // The org.chromium prefix will be removed in bug 1426526. + if (MAC && (filename.startsWith(tmpPath + "/org.chromium.") || + filename.startsWith(tmpPath + "/org.mozilla.ipc."))) { + continue; } let expected = false; diff --git a/browser/base/content/test/performance/browser_startup_mainthreadio.js b/browser/base/content/test/performance/browser_startup_mainthreadio.js index 832f249163d1..57335dd7a7b4 100644 --- a/browser/base/content/test/performance/browser_startup_mainthreadio.js +++ b/browser/base/content/test/performance/browser_startup_mainthreadio.js @@ -884,7 +884,7 @@ add_task(async function() { }); } - let tmpPath = expandWhitelistPath(MAC ? "TmpD:" : "/dev/shm").toLowerCase(); + let tmpPath = expandWhitelistPath("TmpD:").toLowerCase(); let shouldPass = true; for (let phase in phases) { let whitelist = startupPhases[phase]; @@ -919,15 +919,25 @@ add_task(async function() { continue; } - if (!WIN) { - if (filename == "/dev/urandom") { - continue; - } + if (!WIN && filename == "/dev/urandom") { + continue; + } - // Ignore I/O due to IPC. This doesn't really touch the disk. - if (filename.startsWith(tmpPath + "/org.chromium.")) { - continue; - } + // /dev/shm is always tmpfs (a memory filesystem); this isn't + // really I/O any more than mmap/munmap are. + if (LINUX && filename.startsWith("/dev/shm/")) { + continue; + } + + // Shared memory uses temporary files on MacOS <= 10.11 to avoid + // a kernel security bug that will never be patched (see + // https://crbug.com/project-zero/1671 for details). This can + // be removed when we no longer support those OS versions. + // + // The org.chromium prefix will be removed in bug 1426526. + if (MAC && (filename.startsWith(tmpPath + "/org.chromium.") || + filename.startsWith(tmpPath + "/org.mozilla.ipc."))) { + continue; } let expected = false;