Remote Snapshotting serializes images and image buffers by value
Component: WebCore Display Lists | 8a6fc5e
Source/WebCore/platform/graphics/displaylists/DisplayList.cpp
Source/WebCore/platform/graphics/displaylists/DisplayListItems.h
With remote snapshotting, the GPU process records a page into a display list and sends it as DisplayListData to the print process, which replays it into PDF output. Items such as DrawImageBuffer, DrawNativeImage and ClipToNativeImage used to hold live Ref<ImageBuffer>/Ref<const NativeImage> objects that cannot be encoded for another process, so pages with images fell back to GPU-process drawing.
The GPU process now writes each image's pixels into shared memory once and makes items refer to them by RenderingResourceIdentifier. The new ResolvableImage variant lets an item hold either the image or its identifier. The print process loads the images into a new DisplayList::ResourceCache, which rejects duplicate identifiers, wrong image kinds and pixel/size mismatches. createResolved then binds each item through resolveItem.
Several related changes ride along:
Patterngets a new coder, and theSourceBrushcoder now sends its members individually.DrawMeshGradientkeeps mesh gradients by value, serialized with the existing coder.- The print process becomes the owner of the shared memory.
DisplayListDatabecomes move-only in IPC messages.- Grayscale and CMYK images are redrawn into RGB at encode time.
Significance
The print process now decodes far more attacker-influenced data over IPC: image pixels, sizes, scales, patterns and mesh gradients, on top of fonts and nested display lists.
Audit directions
Start with ResourceCache::cacheNativeImage and cacheImageBuffer: check width*height*bytesPerPixel overflow, stride and row-bytes handling, logical-size versus backing-size and scale mismatches, and zero or huge dimensions. Then follow references to identifiers that are missing, of the wrong kind, or present only in another display list (appendDisplayList). Trace nested resolution as well: patterns inside SourceBrush, SourceImage in FEImage filters, and DrawFilteredImageBuffer. ResolvableImage::image() is guarded only by RELEASE_ASSERT(isResolved()), so any item that escapes createResolved unresolved crashes the print process.
The print process maps shared memory while drawing. Check whether the sender can still write to it after the ownership transfer, a TOCTOU between validation and replay, and how handle protection and size are checked at map time.
Also review:
- the new
Patterncoder, the member-wiseSourceBrushcoder and the reused mesh-gradient coder, for unvalidated transforms, repeat flags, NaN or inf values, and empty or huge patch lists; - identifier collisions or reuse across frames and web processes, now that the GPU process assigns identifiers for all of them;
- use-after-move or double-encode of handles on the retry and timeout paths of the move-only
DisplayListData(the new SIGSTOP test exercises the timeout path); - the receiver's interpolation and format assumptions for grayscale and CMYK images redrawn to RGB, which are worth fuzzing.