Skip to content
This repository was archived by the owner on Mar 24, 2022. It is now read-only.
This repository was archived by the owner on Mar 24, 2022. It is now read-only.

Allow use of 4GB aligned heaps to optimize performance of pointer swizzling #276

@shravanrn

Description

@shravanrn

Context
This is part of a series of bugs that I spoke to @tyler @pchickey about. We are currently using Lucet to sandbox libraries in C++ applications. The idea behind this is that using a wasm sandboxed version of the library allows ensuring that a memory safety issue in the library does not automatically result in a memory safety vulnerability in the full application. One of the consumers of this work is the Firefox web browser.

Problem
Since our use case involves sandboxing libraries and not entire applications, data structures may be shared between application and the wasm sandboxed library. Such data structures may contain pointer fields. Given that the representation of pointers differ between the application (which uses simple 64-bit addresses) and the wasm sandboxed library (which uses 32-bit offsets from the sandbox memory base), we need to convert/swizzle pointers at the appropriate locations.

One particularly efficient and elegant approach to swizzle pointers automatically using only C++ operator overloading (if you are curious, this is implemented here) requires the heap to be aligned according to its size. For instance, a 4GB heap would need to be 4GB aligned, a 1GB heap would need to 1GB aligned etc.

Actions
@pchickey mentioned that I could submit a patch for this alignment. I already have a prototype for the same and can clean it up and submit this shortly. The plan is to implement this under an alternate constructor of MmapRegion.

Please let me know if you have any thoughts/concerns.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions