Changeset 248440 in webkit


Ignore:
Timestamp:
Aug 8, 2019 1:32:41 PM (5 years ago)
Author:
pvollan@apple.com
Message:

[Mac] Use the PID of the WebContent process when issuing local file read sandbox extensions
https://bugs.webkit.org/show_bug.cgi?id=200543
Source/WebKit:

Reviewed by Brent Fulgham.

Adopt SPI to issue a process-specific sandbox extension for local file read, passing it the process
identifier of the WebContent process.

  • Shared/Cocoa/SandboxExtensionCocoa.mm:

(WebKit::SandboxExtensionImpl::sandboxExtensionForType):
(WebKit::SandboxExtension::createHandleForReadByPid):

  • Shared/SandboxExtension.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):

Source/WTF:

<rdar://problem/49394015>

Reviewed by Brent Fulgham.

Add new SPI.

  • wtf/Platform.h:
  • wtf/spi/darwin/SandboxSPI.h:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r248386 r248440  
     12019-08-08  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Mac] Use the PID of the WebContent process when issuing local file read sandbox extensions
     4        https://bugs.webkit.org/show_bug.cgi?id=200543
     5        <rdar://problem/49394015>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Add new SPI.
     10
     11        * wtf/Platform.h:
     12        * wtf/spi/darwin/SandboxSPI.h:
     13
    1142019-08-07  Chris Dumez  <cdumez@apple.com>
    215
  • trunk/Source/WTF/wtf/Platform.h

    r248319 r248440  
    15311531#endif
    15321532
     1533#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
     1534#define HAVE_SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID 1
     1535#endif
     1536
    15331537#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000)
    15341538#define HAVE_MDNS_FAST_REGISTRATION 1
  • trunk/Source/WTF/wtf/spi/darwin/SandboxSPI.h

    r243034 r248440  
    6565char *sandbox_extension_issue_generic(const char *extension_class, uint32_t flags);
    6666char *sandbox_extension_issue_mach_to_process_by_pid(const char *extension_class, const char *name, uint32_t flags, pid_t);
     67char *sandbox_extension_issue_file_to_process_by_pid(const char *extension_class, const char *path, uint32_t flags, pid_t);
    6768int sandbox_check(pid_t, const char *operation, enum sandbox_filter_type, ...);
    6869int sandbox_check_by_audit_token(audit_token_t, const char *operation, enum sandbox_filter_type, ...);
  • trunk/Source/WebKit/ChangeLog

    r248438 r248440  
     12019-08-08  Per Arne Vollan  <pvollan@apple.com>
     2
     3        [Mac] Use the PID of the WebContent process when issuing local file read sandbox extensions
     4        https://bugs.webkit.org/show_bug.cgi?id=200543
     5
     6        Reviewed by Brent Fulgham.
     7
     8        Adopt SPI to issue a process-specific sandbox extension for local file read, passing it the process
     9        identifier of the WebContent process.
     10
     11        * Shared/Cocoa/SandboxExtensionCocoa.mm:
     12        (WebKit::SandboxExtensionImpl::sandboxExtensionForType):
     13        (WebKit::SandboxExtension::createHandleForReadByPid):
     14        * Shared/SandboxExtension.h:
     15        * UIProcess/WebPageProxy.cpp:
     16        (WebKit::WebPageProxy::maybeInitializeSandboxExtensionHandle):
     17
    1182019-08-08  Said Abou-Hallawa  <sabouhallawa@apple.com>
    219
  • trunk/Source/WebKit/Shared/Cocoa/SandboxExtensionCocoa.mm

    r244969 r248440  
    101101        case SandboxExtension::Type::Generic:
    102102            return sandbox_extension_issue_generic(path, 0);
     103        case SandboxExtension::Type::ReadByPid:
     104#if HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
     105            return sandbox_extension_issue_file_to_process_by_pid(APP_SANDBOX_READ, path, 0, pid.value());
     106#else
     107            UNUSED_PARAM(pid);
     108            ASSERT_NOT_REACHED();
     109            return nullptr;
     110#endif
    103111        }
    104112    }
     
    337345}
    338346
     347bool SandboxExtension::createHandleForReadByPid(const String& path, ProcessID pid, Handle& handle)
     348{
     349    ASSERT(!handle.m_sandboxExtension);
     350   
     351    handle.m_sandboxExtension = SandboxExtensionImpl::create(path.utf8().data(), Type::ReadByPid, pid);
     352    if (!handle.m_sandboxExtension) {
     353        WTFLogAlways("Could not create a '%s' sandbox extension", path.utf8().data());
     354        return false;
     355    }
     356   
     357    return true;
     358}
     359
    339360SandboxExtension::SandboxExtension(const Handle& handle)
    340361    : m_sandboxExtension(WTFMove(handle.m_sandboxExtension))
  • trunk/Source/WebKit/Shared/SandboxExtension.h

    r243054 r248440  
    5050        Mach,
    5151        Generic,
     52        ReadByPid
    5253    };
    5354
     
    105106    static bool createHandleForGenericExtension(const String& extensionClass, Handle&);
    106107    static bool createHandleForMachLookupByPid(const String& service, ProcessID, Handle&);
     108    static bool createHandleForReadByPid(const String& path, ProcessID, Handle&);
    107109    ~SandboxExtension();
    108110
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r248338 r248440  
    10771077    ASSERT_WITH_SECURITY_IMPLICATION(!WebKit::isInspectorPage(*this));
    10781078
     1079#if PLATFORM(MAC) && HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
     1080    if (SandboxExtension::createHandleForReadByPid("/", processIdentifier(), sandboxExtensionHandle)) {
     1081#else
    10791082    if (SandboxExtension::createHandle("/", SandboxExtension::Type::ReadOnly, sandboxExtensionHandle)) {
     1083#endif
    10801084        willAcquireUniversalFileReadSandboxExtension(process);
    10811085        return;
     
    10901094    auto baseURL = URL(URL(), url.baseAsString());
    10911095    auto basePath = baseURL.fileSystemPath();
    1092     if (!basePath.isNull() && SandboxExtension::createHandle(basePath, SandboxExtension::Type::ReadOnly, sandboxExtensionHandle))
     1096    if (basePath.isNull())
     1097        return;
     1098#if PLATFORM(MAC) && HAVE(SANDBOX_ISSUE_READ_EXTENSION_TO_PROCESS_BY_PID)
     1099    if (SandboxExtension::createHandleForReadByPid(basePath, processIdentifier(), sandboxExtensionHandle))
     1100#else
     1101    if (SandboxExtension::createHandle(basePath, SandboxExtension::Type::ReadOnly, sandboxExtensionHandle))
     1102#endif
    10931103        m_process->assumeReadAccessToBaseURL(*this, baseURL);
    10941104}
Note: See TracChangeset for help on using the changeset viewer.