Skip to content

CONTRACTS: dfcc_is_cprover_symbol now uses allow lists to match symbols #7708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

remi-delmas-3000
Copy link
Collaborator

Assignments to special __CPROVER_* or *$object symbols that are essentially ghost state must not be checked under DFCC. In the same way built-in __CPROVER_ or __VERIFIER or nondet_ functions must not be instrumented by DFCC.

Before, these special symbols were detected by matching a prefix or a suffix, which could allow users to bypass DFCC checks by naming their symbols with these prefixes or suffixes.

Instead we propose to maintain finite sets of function symbols and static symbols which are known to be exempt from DFCC instrumentation, and to test membership in that list.

We add tests that demonstrate that checks are not bypassed even when symbols have the special prefixes.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@remi-delmas-3000
Copy link
Collaborator Author

If anyone can suggest a better solution (this one is sound but could be hard to maintain as we add new special symbols).

@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 🎉

Comparison is base (fb42722) 78.55% compared to head (407914b) 78.57%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #7708      +/-   ##
===========================================
+ Coverage    78.55%   78.57%   +0.01%     
===========================================
  Files         1686     1686              
  Lines       192927   193041     +114     
===========================================
+ Hits        151560   151674     +114     
  Misses       41367    41367              
Impacted Files Coverage Δ
...trument/contracts/dynamic-frames/dfcc_cfg_info.cpp 78.63% <100.00%> (ø)
...ument/contracts/dynamic-frames/dfcc_instrument.cpp 83.43% <100.00%> (ø)
...ontracts/dynamic-frames/dfcc_is_cprover_symbol.cpp 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See suggestion below in order to avoid a global-scoped static object.

@feliperodri feliperodri added aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts labels May 12, 2023
@qinheping qinheping force-pushed the contracts-use-allow-lists branch from ce2c788 to c3f978d Compare May 19, 2023 22:50
@qinheping qinheping force-pushed the contracts-use-allow-lists branch 2 times, most recently from 3a8daf7 to ae73ef9 Compare May 19, 2023 23:16
@qinheping qinheping requested a review from tautschnig May 19, 2023 23:17
/// `__VERIFIER` or `nondet`.
bool dfcc_is_cprover_function_symbol(const irep_idt &id);

/// Returns `true` iff the symbol is one of the know CPROVER static
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Returns `true` iff the symbol is one of the know CPROVER static
/// Returns `true` iff the symbol is one of the known CPROVER static

The result of `dfcc_is_cprover_symbol` is used to skip frame
conditon checks on symbols with special meaning. Before we
were matching symbols based on their prefix, which would
allow users to skip frame condition checks just by naming their
symbols with these prefixes. We now use a closed allow list,
and distinguish function symbolds form static var symbols.
We add test that show that variables named with __CPROVER,
__VERIFIER or nondet prefixes do not bypass frame condition
checks.
@qinheping qinheping force-pushed the contracts-use-allow-lists branch from ae73ef9 to 407914b Compare May 20, 2023 03:24
@tautschnig tautschnig merged commit 8718e33 into diffblue:develop May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
aws Bugs or features of importance to AWS CBMC users Code Contracts Function and loop contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants