Skip to content

[WIP] Reworking implementation of operation masking sanitizer#236

Draft
elazaro-riverside wants to merge 11 commits into
mainfrom
operation-masking-refactor
Draft

[WIP] Reworking implementation of operation masking sanitizer#236
elazaro-riverside wants to merge 11 commits into
mainfrom
operation-masking-refactor

Conversation

@elazaro-riverside

@elazaro-riverside elazaro-riverside commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

Fill this PR in when ready.

@elazaro-riverside elazaro-riverside self-assigned this Jul 6, 2026
@elazaro-riverside elazaro-riverside changed the title [WIP] Refactoring operation masking sanitizer. [WIP] Refactoring operation masking sanitizer Jul 6, 2026
@elazaro-riverside
elazaro-riverside marked this pull request as ready for review July 8, 2026 14:23
@elazaro-riverside
elazaro-riverside marked this pull request as draft July 10, 2026 12:33
@elazaro-riverside
elazaro-riverside force-pushed the operation-masking-refactor branch from ec6295a to 5abd364 Compare July 10, 2026 12:38
@elazaro-riverside elazaro-riverside changed the title [WIP] Refactoring operation masking sanitizer [WIP] Reworking impl of operation masking sanitizer Jul 10, 2026
@elazaro-riverside elazaro-riverside changed the title [WIP] Reworking impl of operation masking sanitizer [WIP] Reworking implementation of operation masking sanitizer Jul 13, 2026
@elazaro-riverside

elazaro-riverside commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

The current operation masking sanitizer creates wrappers that return the first argument as a stub for the original operation. The problem is that the compiler instrumentation replaces all uses with the stub meaning that arguments that are "normal" are replaced as well.

The new approach will focus on transforming the wrappers from stubs into compiler-generated contract enforcement. The key idea is that the compiler won't know about the operation specifically (ex. strcpy). It will know about the preconditions that must hold before allowing the operation to be executed.

@elazaro-riverside

Copy link
Copy Markdown
Collaborator Author

One of the challenges is generating the correct preconditions for the corresponding predicate.

@elazaro-riverside

elazaro-riverside commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator Author

I want to introduce this new abstraction in RESOLVE to represent predicates and contracts.

enum class PredicateKind {
    InBounds,
    NotEqual,
    NotNull,
    Nonzero,
};

// Predicates tell the compiler what
// must be true before executing 
// operation
struct Predicate {
   PredicateKind kind;
   unsigned arg0;
   unsigned arg1;
};

struct Contract {
   std::string fnName;
   std::vector<Predicate> predicates;
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant