You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Injecting the data_flow argument into function definitions and declarations currently can generate code that will cause crashes due to function pointers. Here are a few possible scenarios.
Scenario 1
Only one function can ever be assigned the function pointer
Two functions can be assigned to a function pointer, only one can be instrumented
#include<stdlib.h>#include<stdio.h>// Custom 'allocator' function used instead of// malloc, but only sometimesvoid*my_allocator(intsize) {
returnmalloc(4);
}
intmain(intargc, char*argv[]) {
void* (*allocator)(int);
inti;
intallocsize=64;
// When given an argument, use my_allocator// instead of mallocif (argc>1) {
allocator=my_allocator;
} else {
allocator= (void*)malloc;
}
// Allocate a bufferchar*a= (char*)allocator(allocsize);
// Set values in bufferfor (i=0;i<allocsize;i++){
a[i] =0xff;
}
// Print bufferfor (i=0;i<allocsize;i++){
printf("%02x", a[i]);
}
printf("\n");
}
Since we can't instrument malloc, we can't change the signature of allocator. Since allocator can't be changed, we can't instrument my_allocator. Thus we can't add data_flow to anything here.
Possible Solutions
Refuse to instrument any function that is ever assigned to a function pointer
Use blacklist to config files where a user can specify functions that should not be instrumented. Code to do this is has been around since 931795e, but it might be broken though.
Analyze which functions can possible be assigned to a function pointer. If any of the functions cannot be instrumented, instrument none of them. Otherwise, instrument all of them.
@tleek Do you have anything else to say about the problem or thoughts on how to approach this?
The text was updated successfully, but these errors were encountered:
Injecting the
data_flow
argument into function definitions and declarations currently can generate code that will cause crashes due to function pointers. Here are a few possible scenarios.Scenario 1
Only one function can ever be assigned the function pointer
Here
inc
is safe to instrument, so we can rewrite both it andfn
to add data_flow and everything should continue to work:Scenario 2
Two functions can be assigned to a function pointer, only one can be instrumented
Since we can't instrument
malloc
, we can't change the signature of allocator. Since allocator can't be changed, we can't instrumentmy_allocator
. Thus we can't adddata_flow
to anything here.Possible Solutions
@tleek Do you have anything else to say about the problem or thoughts on how to approach this?
The text was updated successfully, but these errors were encountered: