Changeset 187547 in webkit


Ignore:
Timestamp:
Jul 29, 2015, 8:52:27 AM (10 years ago)
Author:
Michael Catanzaro
Message:

[Seccomp] Further improvements to default web process policy
https://bugs.webkit.org/show_bug.cgi?id=142987

Provide various helper functions to allow more flexible construction of
filesystem access policies.

Reviewed by Žan Doberšek.

Improve the policy. Also, remove ifdefs to reduce potential for breakage in non-default
configurations.

  • Shared/linux/SeccompFilters/SyscallPolicy.cpp:

(WebKit::SyscallPolicy::addDefaultWebProcessPolicy):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r187544 r187547  
     12015-07-29  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [Seccomp] Further improvements to default web process policy
     4        https://bugs.webkit.org/show_bug.cgi?id=142987
     5
     6        Provide various helper functions to allow more flexible construction of
     7        filesystem access policies.
     8
     9        Reviewed by Žan Doberšek.
     10
     11        Improve the policy. Also, remove ifdefs to reduce potential for breakage in non-default
     12        configurations.
     13
     14        * Shared/linux/SeccompFilters/SyscallPolicy.cpp:
     15        (WebKit::SyscallPolicy::addDefaultWebProcessPolicy):
     16
    1172015-07-29  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebKit2/Shared/linux/SeccompFilters/SyscallPolicy.cpp

    r187190 r187547  
    3131#include "PluginSearchPath.h"
    3232#include "WebProcessCreationParameters.h"
     33#include "XDGBaseDirectory.h"
    3334#include <libgen.h>
    3435#include <string.h>
     
    152153    addDirectoryPermission(ASCIILiteral("/"), NotAllowed);
    153154
    154     // Shared libraries, plugins and fonts.
     155    // System library directories
    155156    addDirectoryPermission(ASCIILiteral("/lib"), Read);
    156157    addDirectoryPermission(ASCIILiteral("/lib32"), Read);
     
    159160    addDirectoryPermission(ASCIILiteral("/usr/lib32"), Read);
    160161    addDirectoryPermission(ASCIILiteral("/usr/lib64"), Read);
     162    addDirectoryPermission(ASCIILiteral("/usr/local/lib"), Read);
     163    addDirectoryPermission(ASCIILiteral("/usr/local/lib32"), Read);
     164    addDirectoryPermission(ASCIILiteral("/usr/local/lib64"), Read);
     165    addDirectoryPermission(ASCIILiteral(LIBDIR), Read);
     166
     167    // System data directories
    161168    addDirectoryPermission(ASCIILiteral("/usr/share"), Read);
    162 
    163     // Support for alternative install prefixes, e.g. /usr/local.
     169    addDirectoryPermission(ASCIILiteral("/usr/local/share"), Read);
    164170    addDirectoryPermission(ASCIILiteral(DATADIR), Read);
    165     addDirectoryPermission(ASCIILiteral(LIBDIR), Read);
    166 
    167     // Plugin search path
     171
     172    // NPAPI plugins
    168173    for (String& path : pluginsDirectories())
    169174        addDirectoryPermission(path, Read);
     
    171176    // SSL Certificates.
    172177    addDirectoryPermission(ASCIILiteral("/etc/ssl/certs"), Read);
    173 
    174     // Fontconfig cache.
    175     addDirectoryPermission(ASCIILiteral("/etc/fonts"), Read);
    176     addDirectoryPermission(ASCIILiteral("/var/cache/fontconfig"), Read);
    177178
    178179    // Audio devices, random number generators, etc.
     
    221222    addDirectoryPermission("/run/user/" + String::number(getuid()), ReadAndWrite);
    222223
    223     // Needed by WebKit's memory pressure handler
     224    // Needed by WebKit's memory pressure handler.
    224225    addFilePermission(ASCIILiteral("/sys/fs/cgroup/memory/memory.pressure_level"), Read);
    225226    addFilePermission(ASCIILiteral("/sys/fs/cgroup/memory/cgroup.event_control"), Read);
    226227
    227     char* homeDir = getenv("HOME");
    228     if (homeDir) {
    229         // X11 connection token.
    230         addFilePermission(String::fromUTF8(homeDir) + "/.Xauthority", Read);
    231     }
     228    // X11 connection token.
     229    addFilePermission(userHomeDirectory() + "/.Xauthority", Read);
    232230
    233231    // MIME type resolution.
    234     char* dataHomeDir = getenv("XDG_DATA_HOME");
    235     if (dataHomeDir)
    236         addDirectoryPermission(String::fromUTF8(dataHomeDir) + "/mime", Read);
    237     else if (homeDir)
    238         addDirectoryPermission(String::fromUTF8(homeDir) + "/.local/share/mime", Read);
    239 
    240 #if ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS)
    241     // Needed on most non-Debian distros by libxshmfence <= 1.1, or newer
    242     // libxshmfence with older kernels (linux <= 3.16), for DRI3 shared memory.
    243     // FIXME Try removing this permission when we can rely on a newer libxshmfence.
    244     // See http://code.google.com/p/chromium/issues/detail?id=415681
    245     addDirectoryPermission(ASCIILiteral("/var/tmp"), ReadAndWrite);
    246 
    247     // Optional Mesa DRI configuration file
    248     addFilePermission(ASCIILiteral("/etc/drirc"), Read);
    249     if (homeDir)
    250         addFilePermission(String::fromUTF8(homeDir) + "/.drirc", Read);
    251 
    252     // Mesa uses udev.
     232    addDirectoryPermission(userDataDirectory() + "/mime", Read);
     233
     234    // Needed by NVIDIA proprietary graphics driver.
     235    addDirectoryPermission(userHomeDirectory() + "/.nv", ReadAndWrite);
     236
     237    // Needed by udev.
    253238    addDirectoryPermission(ASCIILiteral("/etc/udev"), Read);
    254239    addDirectoryPermission(ASCIILiteral("/run/udev"), Read);
     
    256241    addDirectoryPermission(ASCIILiteral("/sys/class"), Read);
    257242    addDirectoryPermission(ASCIILiteral("/sys/devices"), Read);
    258 #endif
    259 
    260     // Needed by NVIDIA proprietary graphics driver
    261     if (homeDir)
    262         addDirectoryPermission(String::fromUTF8(homeDir) + "/.nv", ReadAndWrite);
     243
     244    // PulseAudio
     245    addFilePermission(ASCIILiteral("/etc/asound.conf"), Read);
     246    addDirectoryPermission(userConfigDirectory() + "/.pulse", Read);
     247    addDirectoryPermission(userHomeDirectory() + "/.pulse", Read);
     248
     249    // Mesa
     250    addFilePermission(ASCIILiteral("/etc/drirc"), Read);
     251    addFilePermission(userHomeDirectory() + "/.drirc", Read);
     252    addFilePermission(ASCIILiteral("/sys/fs/selinux/booleans/allow_execmem"), Read);
     253
     254    // GStreamer
     255    addDirectoryPermission(String::fromUTF8(LIBEXECDIR) + "/gstreamer-1.0", Read);
     256    addDirectoryPermission(userDataDirectory() + "/gstreamer-1.0", Read);
     257    addDirectoryPermission(userCacheDirectory() + "/gstreamer-1.0", ReadAndWrite);
     258    addDirectoryPermission(userHomeDirectory() + "/.frei0r-1", ReadAndWrite);
     259    if (char* gstreamerPluginDirectory = getenv("GST_PLUGIN_PATH_1_0"))
     260        addDirectoryPermission(gstreamerPluginDirectory, Read);
     261    if (char* gstreamerRegistryFile = getenv("GST_REGISTRY_1_0"))
     262        addFilePermission(gstreamerRegistryFile, ReadAndWrite);
     263
     264    // Fontconfig
     265    addDirectoryPermission(userCacheDirectory() + "/fontconfig", ReadAndWrite);
     266    addDirectoryPermission(userConfigDirectory() + "/fontconfig", Read);
     267    addDirectoryPermission(userConfigDirectory() + "/fonts", Read);
     268    addDirectoryPermission(userDataDirectory() + "/fonts", Read);
     269    addDirectoryPermission(userHomeDirectory() + "/fontconfig", Read);
     270    addDirectoryPermission(userHomeDirectory() + "/.fonts", Read);
     271    addDirectoryPermission(ASCIILiteral("/etc/fonts"), Read);
     272    addDirectoryPermission(ASCIILiteral("/var/cache/fontconfig"), Read);
    263273
    264274#if ENABLE(DEVELOPER_MODE) && defined(SOURCE_DIR)
     
    266276    // from the build root directory and they also need access to layout test
    267277    // files.
    268     char* sourceDir = canonicalize_file_name(SOURCE_DIR);
    269     if (sourceDir) {
    270         addDirectoryPermission(String::fromUTF8(sourceDir), SyscallPolicy::ReadAndWrite);
    271         free(sourceDir);
    272     }
     278    addDirectoryPermission(String::fromUTF8(SOURCE_DIR), SyscallPolicy::ReadAndWrite);
    273279#endif
    274280}
Note: See TracChangeset for help on using the changeset viewer.