Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
ab8f901f
Commit
ab8f901f
authored
3 years ago
by
Michele Alberti
Committed by
David Bühler
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] Untaint left value only when the corresponding location is a singleton.
parent
44bb6ab0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/plugins/value/domains/taint_domain.ml
+4
-2
4 additions, 2 deletions
src/plugins/value/domains/taint_domain.ml
tests/value/oracle/taint.res.oracle
+37
-12
37 additions, 12 deletions
tests/value/oracle/taint.res.oracle
tests/value/taint.c
+14
-0
14 additions, 0 deletions
tests/value/taint.c
with
55 additions
and
14 deletions
src/plugins/value/domains/taint_domain.ml
+
4
−
2
View file @
ab8f901f
...
@@ -204,8 +204,8 @@ module TransferTaint = struct
...
@@ -204,8 +204,8 @@ module TransferTaint = struct
state
state
|
Kstmt
stmt
->
|
Kstmt
stmt
->
let
to_loc
=
loc_of_lval
valuation
in
let
to_loc
=
loc_of_lval
valuation
in
let
ploc
=
to_loc
lv
.
Eval
.
lval
in
let
lv_zone
=
let
lv_zone
=
let
ploc
=
to_loc
lv
.
Eval
.
lval
in
let
loc
=
Precise_locs
.
imprecise_location
ploc
in
let
loc
=
Precise_locs
.
imprecise_location
ploc
in
Locations
.
enumerate_valid_bits
Write
loc
Locations
.
enumerate_valid_bits
Write
loc
in
in
...
@@ -249,7 +249,9 @@ module TransferTaint = struct
...
@@ -249,7 +249,9 @@ module TransferTaint = struct
in
in
if
intersect_state
if
intersect_state
then
{
state
with
locs_data
=
Zone
.
join
state
.
locs_data
lv_zone
}
then
{
state
with
locs_data
=
Zone
.
join
state
.
locs_data
lv_zone
}
else
{
state
with
locs_data
=
Zone
.
diff
state
.
locs_data
lv_zone
}
else
if
Precise_locs
.
cardinal_zero_or_one
ploc
then
{
state
with
locs_data
=
Zone
.
diff
state
.
locs_data
lv_zone
}
else
state
in
in
`Value
state
`Value
state
...
...
This diff is collapsed.
Click to expand it.
tests/value/oracle/taint.res.oracle
+
37
−
12
View file @
ab8f901f
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
undet ∈ [--..--]
undet ∈ [--..--]
tainted ∈ {0}
tainted ∈ {0}
[eva] computing for function taint_basic <- main.
[eva] computing for function taint_basic <- main.
Called from tests/value/taint.c:13
1
.
Called from tests/value/taint.c:1
4
3.
[eva] tests/value/taint.c:34:
[eva] tests/value/taint.c:34:
Frama_C_dump_each:
Frama_C_dump_each:
# taint:
# taint:
...
@@ -19,7 +19,7 @@
...
@@ -19,7 +19,7 @@
[eva] Recording results for taint_basic
[eva] Recording results for taint_basic
[eva] Done for function taint_basic
[eva] Done for function taint_basic
[eva] computing for function taint_assume_1 <- main.
[eva] computing for function taint_assume_1 <- main.
Called from tests/value/taint.c:1
3
4.
Called from tests/value/taint.c:14
6
.
[eva:loop-unroll] tests/value/taint.c:47: Automatic loop unrolling.
[eva:loop-unroll] tests/value/taint.c:47: Automatic loop unrolling.
[eva] tests/value/taint.c:48:
[eva] tests/value/taint.c:48:
Frama_C_dump_each:
Frama_C_dump_each:
...
@@ -80,7 +80,7 @@
...
@@ -80,7 +80,7 @@
[eva] Recording results for taint_assume_1
[eva] Recording results for taint_assume_1
[eva] Done for function taint_assume_1
[eva] Done for function taint_assume_1
[eva] computing for function taint_assume_2 <- main.
[eva] computing for function taint_assume_2 <- main.
Called from tests/value/taint.c:1
35
.
Called from tests/value/taint.c:1
47
.
[eva] tests/value/taint.c:76:
[eva] tests/value/taint.c:76:
Frama_C_dump_each:
Frama_C_dump_each:
# taint:
# taint:
...
@@ -91,16 +91,28 @@
...
@@ -91,16 +91,28 @@
==END OF DUMP==
==END OF DUMP==
[eva] Recording results for taint_assume_2
[eva] Recording results for taint_assume_2
[eva] Done for function taint_assume_2
[eva] Done for function taint_assume_2
[eva] computing for function taint_undet_locs <- main.
Called from tests/value/taint.c:149.
[eva] tests/value/taint.c:88:
Frama_C_dump_each:
# taint:
Locations (data):
x; y; t
Locations (control):
\nothing
==END OF DUMP==
[eva] Recording results for taint_undet_locs
[eva] Done for function taint_undet_locs
[eva] computing for function taint_spec_assigns <- main.
[eva] computing for function taint_spec_assigns <- main.
Called from tests/value/taint.c:1
38
.
Called from tests/value/taint.c:1
52
.
[eva] using specification for function taint_spec_assigns
[eva] using specification for function taint_spec_assigns
[eva] Done for function taint_spec_assigns
[eva] Done for function taint_spec_assigns
[eva] tests/value/taint.c:14
0
:
[eva] tests/value/taint.c:1
5
4:
Frama_C_domain_show_each:
Frama_C_domain_show_each:
l : # taint: false
l : # taint: false
[eva] computing for function taint_goto_1 <- main.
[eva] computing for function taint_goto_1 <- main.
Called from tests/value/taint.c:1
42
.
Called from tests/value/taint.c:1
56
.
[eva] tests/value/taint.c:
95
:
[eva] tests/value/taint.c:
107
:
Frama_C_dump_each:
Frama_C_dump_each:
# taint:
# taint:
Locations (data):
Locations (data):
...
@@ -111,8 +123,8 @@
...
@@ -111,8 +123,8 @@
[eva] Recording results for taint_goto_1
[eva] Recording results for taint_goto_1
[eva] Done for function taint_goto_1
[eva] Done for function taint_goto_1
[eva] computing for function taint_goto_2 <- main.
[eva] computing for function taint_goto_2 <- main.
Called from tests/value/taint.c:1
43
.
Called from tests/value/taint.c:1
57
.
[eva] tests/value/taint.c:1
15
:
[eva] tests/value/taint.c:1
27
:
Frama_C_dump_each:
Frama_C_dump_each:
# taint:
# taint:
Locations (data):
Locations (data):
...
@@ -123,9 +135,9 @@
...
@@ -123,9 +135,9 @@
[eva] Recording results for taint_goto_2
[eva] Recording results for taint_goto_2
[eva] Done for function taint_goto_2
[eva] Done for function taint_goto_2
[eva] computing for function taint_call <- main.
[eva] computing for function taint_call <- main.
Called from tests/value/taint.c:1
4
6.
Called from tests/value/taint.c:16
0
.
[eva] computing for function taint_basic <- taint_call <- main.
[eva] computing for function taint_basic <- taint_call <- main.
Called from tests/value/taint.c:1
2
3.
Called from tests/value/taint.c:13
5
.
[eva] tests/value/taint.c:34:
[eva] tests/value/taint.c:34:
Frama_C_dump_each:
Frama_C_dump_each:
# taint:
# taint:
...
@@ -136,7 +148,7 @@
...
@@ -136,7 +148,7 @@
==END OF DUMP==
==END OF DUMP==
[eva] Recording results for taint_basic
[eva] Recording results for taint_basic
[eva] Done for function taint_basic
[eva] Done for function taint_basic
[eva] tests/value/taint.c:1
26
:
[eva] tests/value/taint.c:1
38
:
Frama_C_domain_show_each:
Frama_C_domain_show_each:
x : # taint: false
x : # taint: false
[eva] Recording results for taint_call
[eva] Recording results for taint_call
...
@@ -170,6 +182,11 @@
...
@@ -170,6 +182,11 @@
y ∈ {0} or UNINITIALIZED
y ∈ {0} or UNINITIALIZED
z ∈ {1} or UNINITIALIZED
z ∈ {1} or UNINITIALIZED
t ∈ [--..--]
t ∈ [--..--]
[eva:final-states] Values at end of function taint_undet_locs:
x ∈ {0}
y ∈ {0}
t ∈ {0}
p ∈ {{ &x ; &y }}
[eva:final-states] Values at end of function main:
[eva:final-states] Values at end of function main:
tainted ∈ {0}
tainted ∈ {0}
l ∈ [--..--] or UNINITIALIZED
l ∈ [--..--] or UNINITIALIZED
...
@@ -186,6 +203,8 @@
...
@@ -186,6 +203,8 @@
[from] Done for function taint_goto_1
[from] Done for function taint_goto_1
[from] Computing for function taint_goto_2
[from] Computing for function taint_goto_2
[from] Done for function taint_goto_2
[from] Done for function taint_goto_2
[from] Computing for function taint_undet_locs
[from] Done for function taint_undet_locs
[from] Computing for function main
[from] Computing for function main
[from] Computing for function taint_spec_assigns <-main
[from] Computing for function taint_spec_assigns <-main
[from] Done for function taint_spec_assigns
[from] Done for function taint_spec_assigns
...
@@ -206,6 +225,8 @@
...
@@ -206,6 +225,8 @@
NO EFFECTS
NO EFFECTS
[from] Function taint_spec_assigns:
[from] Function taint_spec_assigns:
l FROM t
l FROM t
[from] Function taint_undet_locs:
NO EFFECTS
[from] Function main:
[from] Function main:
tainted FROM \nothing
tainted FROM \nothing
\result FROM \nothing
\result FROM \nothing
...
@@ -234,6 +255,10 @@
...
@@ -234,6 +255,10 @@
x; y; z; t
x; y; z; t
[inout] Inputs for function taint_goto_2:
[inout] Inputs for function taint_goto_2:
undet
undet
[inout] Out (internal) for function taint_undet_locs:
x; y; t; p; tmp
[inout] Inputs for function taint_undet_locs:
undet
[inout] Out (internal) for function main:
[inout] Out (internal) for function main:
tainted; l; __retres
tainted; l; __retres
[inout] Inputs for function main:
[inout] Inputs for function main:
...
...
This diff is collapsed.
Click to expand it.
tests/value/taint.c
+
14
−
0
View file @
ab8f901f
...
@@ -76,6 +76,18 @@ void taint_assume_2() {
...
@@ -76,6 +76,18 @@ void taint_assume_2() {
Frama_C_dump_each
();
Frama_C_dump_each
();
}
}
void
taint_undet_locs
()
{
int
x
,
y
,
t
=
0
;
int
*
p
=
undet
?
&
x
:
&
y
;
//@ taint t;
x
=
t
;
y
=
t
;
/* Since 'p' may point to either 'x' or 'y', this assignment does not untaint
'x' nor 'y' (which must both remain data-tainted). */
*
p
=
0
;
Frama_C_dump_each
();
}
/*@ assigns *l \from t; */
/*@ assigns *l \from t; */
void
taint_spec_assigns
(
int
*
l
,
int
t
);
void
taint_spec_assigns
(
int
*
l
,
int
t
);
...
@@ -134,6 +146,8 @@ int main(void) {
...
@@ -134,6 +146,8 @@ int main(void) {
taint_assume_1
();
taint_assume_1
();
taint_assume_2
();
taint_assume_2
();
taint_undet_locs
();
int
l
;
int
l
;
taint_spec_assigns
(
&
l
,
tainted
);
taint_spec_assigns
(
&
l
,
tainted
);
/* Here 'l' must be tainted. */
/* Here 'l' must be tainted. */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment