Skip to content

Tests demonstrating pointer-encoding unsoundness #5823

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
merged 1 commit into from
Feb 16, 2021

Conversation

tautschnig
Copy link
Collaborator

The tests exercise the way the back-end encodes pointers. Upcoming
encoding changes will ensure that these can soundly be handled.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@codecov
Copy link

codecov bot commented Feb 12, 2021

Codecov Report

Merging #5823 (e5e8239) into develop (09251eb) will increase coverage by 0.00%.
The diff coverage is 83.62%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #5823   +/-   ##
========================================
  Coverage    72.85%   72.85%           
========================================
  Files         1423     1421    -2     
  Lines       154072   154130   +58     
========================================
+ Hits        112244   112292   +48     
- Misses       41828    41838   +10     
Impacted Files Coverage Δ
src/solvers/flattening/boolbv_union.cpp 57.14% <0.00%> (ø)
src/solvers/flattening/boolbv_with.cpp 65.30% <0.00%> (ø)
src/solvers/flattening/boolbv.h 69.56% <50.00%> (-4.12%) ⬇️
src/solvers/flattening/bv_pointers.cpp 82.93% <86.02%> (+0.52%) ⬆️
src/solvers/flattening/boolbv_byte_extract.cpp 70.00% <100.00%> (ø)
src/solvers/flattening/boolbv_byte_update.cpp 100.00% <100.00%> (ø)
src/solvers/flattening/boolbv_width.cpp 76.69% <100.00%> (-0.23%) ⬇️
src/solvers/flattening/boolbv_width.h 100.00% <100.00%> (ø)
src/solvers/flattening/bv_pointers.h 100.00% <100.00%> (ø)
src/util/endianness_map.h 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92659b5...e5e8239. Read the comment docs.

int offset = OFFSET;
int n = 2;
__CPROVER_assert(&((char *)base)[offset] != 0, "no wrap-around expected");
}
Copy link
Member

Choose a reason for hiding this comment

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

This one feels like it's a bit overfitted to the current encoding -- how about checking that the conversion to an integer doesn't get smaller?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

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

Without knowing the bigger picture of what you are planning with pointer encodings it's a bit hard to say but... I'm not particularly comfortable with these.


main()
{
char *base = BASE;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a little concerned by this. As I understand CBMC's memory model we do not support literal addresses. I don't think we are required to do so by the standard either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd say we half-support them... And I'd really like to see that fixed as well, might just happen along the way ;-)


if(
(unsigned long)p >
42) // unsoundly evaluates to true due to pointer encoding
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this unsound? ISO-9899 allows conversion of pointers to integers but doesn't say what they will be. Thinking about actual platforms, this kind of thing could be ASLR dependent!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed, and I would thus argue that the assertion below ought to be considered reachable by a sound verification tool (i.e., there exists some system configuration under which p is less or equal to 42).

The tests exercise the way the back-end encodes pointers. Upcoming
encoding changes will ensure that these can soundly be handled.
@tautschnig tautschnig force-pushed the pointer-encoding-tests branch from a4e2c1b to e5e8239 Compare February 16, 2021 10:46
@tautschnig tautschnig self-assigned this Feb 16, 2021
@tautschnig tautschnig merged commit 2006bef into diffblue:develop Feb 16, 2021
@tautschnig tautschnig deleted the pointer-encoding-tests branch February 16, 2021 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants