• Matthew Cary's avatar
    media/base: Add new UnalignedWritableMapping type. · 4254e2b2
    Matthew Cary authored
    Where the old UnalignedSharedMemory type is created from a legacy
    SharedMemoryHandle, this new type is created from a new shared memory
    API instance of UnsafeSharedMemoryRegion. This changes both the
    ownership semantics and mapping details from UnalignedSharedMemory: the
    new UnalignedWritableMapping does not own the region backing the
    shared memory, and only owns the mapping itself. Because of this, the
    region is mapped upon construction rather than with a later MapAt
    call.
    
    These changes do not seem to affect behavior in a practical manner.
    
    This change also removes the read-only bit. This is no longer
    meaningful, as only the mapping is owned; in addition the original use
    of this variable was not correct, as explained in detail in
    https://goo.gl/HmBYy6. (TL;DR: on some platforms, being read-only is a
    characteristic of the underlying OS region, and cannot be set in some
    processes without affecting the protection in all processes. As this
    behavior is incompatible with usage, this means that sometimes shared
    memory which has been declared read-only is not, in fact, read-only, and
    could be exploited by rouge processes).
    
    Finally, a the new UnalignedWritableMapping contains a shim
    constructor which takes a legacy SharedMemoryHandle. The ownership
    semantics are the same a the region-created version, that is, the handle
    is *not* owned by the UnalignedWritableMapping instance.
    
    This shim allows us to convert all users of this class one-by-one, and
    confirm that the new ownership semantics are correctly handled. After
    this is done, the BitstreamBuffer class, which is at the heart of the
    IPCs involved, can be converted to the new API without needing to change
    ownership semantics at the same time.
    
    See the bug for an overview of the entire process.
    
    Bug: 849207
    Change-Id: Ibe4bbb48f7bea3fb31728bf98133ede0228b9801
    Reviewed-on: https://chromium-review.googlesource.com/1116703Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
    Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
    Reviewed-by: default avatarAlexandr Ilin <alexilin@chromium.org>
    Commit-Queue: Matthew Cary <mattcary@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#570930}
    4254e2b2
DEPS 764 Bytes