-
Notifications
You must be signed in to change notification settings - Fork 273
transfer taint with memcpy #1574
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
default: tests.log | ||
|
||
test: | ||
@../test.pl -p -c ../../../src/goto-analyzer/goto-analyzer | ||
|
||
tests.log: ../test.pl | ||
@../test.pl -p -c ../../../src/goto-analyzer/goto-analyzer | ||
|
||
show: | ||
@for dir in *; do \ | ||
if [ -d "$$dir" ]; then \ | ||
vim -o "$$dir/*.java" "$$dir/*.out"; \ | ||
fi; \ | ||
done; | ||
|
||
clean: | ||
find -name '*.out' -execdir $(RM) '{}' \; | ||
find -name '*.gb' -execdir $(RM) '{}' \; | ||
$(RM) tests.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#include <string.h> | ||
|
||
void my_f(void *) { } | ||
void my_h(void *) { } | ||
|
||
void my_function() | ||
{ | ||
void *o1; | ||
my_f(o1); // T1 source | ||
|
||
void *o2; | ||
memcpy(o2, o1, 100); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potentially removing taint is an issue. |
||
|
||
my_h(o2); // T1 sink | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[ | ||
{ "id": "my_f", "kind": "source", "where": "parameter1", "taint": "T1", "function": "my_f" }, | ||
{ "id": "my_h", "kind": "sink", "where": "parameter1", "taint": "T1", "function": "my_h", "message": "There is a T1 flow" } | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CORE | ||
main.o | ||
--taint taint.json | ||
^EXIT=0$ | ||
^SIGNAL=0$ | ||
^file main.c line 12( function .*)?: There is a T1 flow \(taint rule my_h\)$ | ||
-- |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -380,6 +380,19 @@ void custom_bitvector_domaint::transform( | |
} | ||
} | ||
} | ||
else if(identifier=="memcpy" || | ||
identifier=="memmove") | ||
{ | ||
if(code_function_call.arguments().size()==3) | ||
{ | ||
// we copy all tracked bits from op1 to op0 | ||
// we do not consider any bits attached to the size op2 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right now the analysis only tracks taint on pointers, but the size is an integer. |
||
dereference_exprt lhs_deref(code_function_call.arguments()[0]); | ||
dereference_exprt rhs_deref(code_function_call.arguments()[1]); | ||
|
||
assign_struct_rec(from, lhs_deref, rhs_deref, cba, ns); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment on why we're ignoring the non-3-op case? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. memmove: yes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, forget memset |
||
} | ||
else | ||
{ | ||
goto_programt::const_targett next=from; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be accompanied by a suitable
#include