Skip to content
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

Soundness bug with unconstrained pointers #2617

Open
qaphla opened this issue Jul 25, 2018 · 3 comments
Open

Soundness bug with unconstrained pointers #2617

qaphla opened this issue Jul 25, 2018 · 3 comments
Labels
enhancement Version 6 Pull requests and issues requiring a major version bump

Comments

@qaphla
Copy link

qaphla commented Jul 25, 2018

The handling of writes to unconstrained pointers treats all writes, regardless of offset, as writing to a single object. This can result in soundness issues. See, for example, the following program, which CBMC verifies:

#include <assert.h>

void main()
{
  int *x;
  x[0] = 1;
  x[1] = 2;
  assert(x[0] == 2);
}

While unconstrained pointers are unlikely to occur in actual C code, some goto-instrument passes (in particular, the code-contracts passes) create unconstrained variables for checking purposes, and are unsound as a result of this issue.

@kroening
Copy link
Member

The unsoundness is fixed by giving the --pointer-check option to CBMC. This option should become default at some point.

For contracts, you will need to be able to express a precondition that requires a pointer to point to something. This feature is yet to be implemented.

@martin-cs
Copy link
Collaborator

martin-cs commented Jul 26, 2018

Thanks for the bug report. Uninitialised / unconstrained pointers are always an issue as it is far from clear what the semantics should be. For example, if you have typedef struct _tree { int label; struct _tree *left, struct _tree *right} tree; and are verifying a function int search (tree * root), should root->value work? What about root->left->value? Is it different to root->right->value? Is it possible to have root->right->right == root->right?

Our current approach to handling this is to ask users to build a calling context that constructs what they think are valid memory configurations. This could be automated to some degree but it would likely require many SAT calls and something like Cristina's small model property for heaps.

@TGWDB TGWDB added the Version 6 Pull requests and issues requiring a major version bump label Feb 21, 2023
@esteffin esteffin moved this to Candidates in Version 6 Nov 9, 2023
@esteffin
Copy link
Contributor

esteffin commented Nov 9, 2023

Adding --pointer-check as default parameter to CBMC has been proposed to be part of version 6 here #7975.

Adding contracts support to express a precondition that requires a pointer to point to something has to be addressed separately, so it will be left out of version 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Version 6 Pull requests and issues requiring a major version bump
Projects
Status: Candidates
Development

No branches or pull requests

5 participants