-
Notifications
You must be signed in to change notification settings - Fork 262
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6076 from TGWDB/inlining-bug-6065
Ensure locations are updated during instrumenting preconditions
- Loading branch information
Showing
7 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
This subdirectory is for tests where goto-cc is used to produce | ||
a goto binary that is then passed to goto-analyzer. There is also | ||
the option to have a custom script to produce the goto binary | ||
should this require special handling or multiple steps. This | ||
script is run if the root name of the test file has a script with | ||
the same filename. For example, if the desc file specifies | ||
test.c as the test file then the chain.sh script will check for | ||
the existence of test.sh and if test.sh exists then it will be used | ||
to build the goto binary (assumed to be test.gb). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
regression/goto-cc-goto-analyzer/instrument_preconditions_locations/s2n_hash_inlined.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// This file is highly reduced from some open source projects. | ||
// The following four lines are adapted from the openssl library | ||
// Full repository here: | ||
// Exact file adapted from here: https://github.com/openssl/openssl/tree/master | ||
// https://github.com/openssl/openssl/blob/master/crypto/evp/evp_local.h | ||
struct evp_md_ctx_st | ||
{ | ||
const void *digest; | ||
}; | ||
// The rest of this file is adapted from, various files in the | ||
// AWS s2n library. Full repository and licence information is | ||
// available here: https://github.com/aws/s2n-tls | ||
// Note that this is a highly cut down synthesis of many files | ||
// with most of their content and structure reduced. | ||
struct s2n_evp_digest | ||
{ | ||
const void *ctx; | ||
}; | ||
union s2n_hash_low_level_digest { | ||
}; | ||
struct s2n_hash_evp_digest | ||
{ | ||
struct s2n_evp_digest evp_md5_secondary; | ||
}; | ||
struct s2n_hash_state | ||
{ | ||
const struct s2n_hash *hash_impl; | ||
union { | ||
union s2n_hash_low_level_digest low_level; | ||
struct s2n_hash_evp_digest high_level; | ||
} digest; | ||
}; | ||
struct s2n_hash | ||
{ | ||
int (*free)(struct s2n_hash_state *state); | ||
}; | ||
void EVP_MD_CTX_free(struct evp_md_ctx_st *ctx) | ||
{ | ||
free(ctx->digest); | ||
free(ctx); | ||
} | ||
static int s2n_evp_hash_free(struct s2n_hash_state *state) | ||
{ | ||
(EVP_MD_CTX_free((state->digest.high_level.evp_md5_secondary.ctx))); | ||
return 0; | ||
} | ||
static const struct s2n_hash s2n_evp_hash = { | ||
.free = &s2n_evp_hash_free, | ||
}; | ||
static int s2n_hash_set_impl(struct s2n_hash_state *state) | ||
{ | ||
state->hash_impl = &s2n_evp_hash; | ||
return 0; | ||
} |
5 changes: 5 additions & 0 deletions
5
regression/goto-cc-goto-analyzer/instrument_preconditions_locations/simple.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// This is highly adapted from the AWS s2n library. | ||
// Full repository and information here: https://github.com/aws/s2n-tls | ||
void s2n_hash_free_harness() | ||
{ | ||
} |
16 changes: 16 additions & 0 deletions
16
regression/goto-cc-goto-analyzer/instrument_preconditions_locations/test.desc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
CORE | ||
test.c | ||
--verify | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
Checking assertions | ||
^\[EVP_MD_CTX_free.precondition_instance.1\] line \d+ free argument must be NULL or valid pointer: SUCCESS | ||
-- | ||
Invariant check failed | ||
-- | ||
This test checks that after building the goto binary (see test.sh) | ||
that there is no errors that lead to invariant violations. | ||
This was created after a bug was found due to the | ||
instrument_preconditions code not correctly fixing locations and | ||
the invariant check of partial inlining detecting this location | ||
inconsistency. |
18 changes: 18 additions & 0 deletions
18
regression/goto-cc-goto-analyzer/instrument_preconditions_locations/test.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
goto_cc=$1 | ||
is_windows=$2 | ||
|
||
if [[ "${is_windows}" == "true" ]]; then | ||
${goto_cc} --export-file-local-symbols simple.c | ||
mv simple.exe simple.gb | ||
${goto_cc} --export-file-local-symbols s2n_hash_inlined.c | ||
mv s2n_hash_inlined.exe s2n_hash_inlined.gb | ||
${goto_cc} --function s2n_hash_free_harness simple.gb s2n_hash_inlined.gb | ||
mv simple.exe test.gb | ||
else | ||
${goto_cc} --export-file-local-symbols simple.c -o simple.gb | ||
${goto_cc} --export-file-local-symbols s2n_hash_inlined.c -o s2n_hash_inlined.gb | ||
${goto_cc} --function s2n_hash_free_harness simple.gb s2n_hash_inlined.gb -o test.gb | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters