Skip to content

Newtypes for stronger control flow integrity #1556

Open
@SoniEx2

Description

@SoniEx2

A newtype is a (mostly) zero-cost wrapper for an existing type. When it comes to the type stack, a newtype and its underlying type are indistinguishable. When it comes to certain interactions, they are very much distinguishable. In particular:

  1. On a call_indirect, newtypes of the expected function (as per type of the call_indirect) and of the passed function (as per type in function table) must match.
  2. Imports must also match newtypes.

So for example, a string-ptr newtype (i32) is just an i32 and can be manipulated and used like an i32, but a function that takes a string-ptr and a function that takes an i32 are not compatible.

Thoughts?

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