-
Notifications
You must be signed in to change notification settings - Fork 5
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
PrevLocation incorrect #6
Comments
(I guess we might have different understandings on the instrumentation code) This is how we design the implementation: Our instrumentation tracks
will (only) store an unique marked block ID at the end of each marked block. And this code block: Value *L = NULL;
if (PI == PE) {
L = ConstantInt::get(Int32Ty, genLabel());
} else {
auto *PN = PHINode::Create(Int32Ty, 0, "", &*BB.begin());
DenseMap<BasicBlock *, unsigned> PredMap;
for (auto PI = pred_begin(&BB), PE = pred_end(&BB);
PI != PE; ++PI
) {
BasicBlock *PBB = *PI;
auto It = PredMap.insert({PBB, genLabel()});
unsigned Label = It.first->second;
PN->addIncoming(ConstantInt::get(Int32Ty, Label), PBB);
}
L = PN;
} will generate an unique edge ID for each incoming edge of the marked block. Then we utilize LLVM PHINode to get the edge ID of incoming edge during execution, and xor the Value *MapPtrIdx = IRB.CreateGEP(MapPtr,
IRB.CreateXor(PrevLocCasted, L)); So for you question 2, the instrumentation is like the following figure: We don't set the The reason why we still xor the For you question 1, we believe the reason why AFL needs to shift Notice that we don't initialize the |
AFL does basic block instrumentation and the edge ID comes from xor'ing the values of two blocks. In your instrumentation you are doing a path instrumentation (so even more than edge instrumentation). IMHO in your case the xor'ing is unnecessary, as your ID is the value that afl would calculate by And in cases where you need prev_loc to calculcate an edge ID I don't understand why you use a prev_loc that isnt really a prev_loc if there are other instrumented paths in between. This has implications I am too tired to see ;) So in my understanding you instrument in two different ways the same thing (and edge/path). this is what confuses me :) (and yes, it is my understanding too that the >> 1 comes from handling loop blocks, however it has more implications when it comes to pc-guard or qemu coverage) |
Yes, we need the Only taking the edge ID is not enough to distinguish the paths from green arrow and from purple arrow. That's why we xor the |
The basic block which writes to the coverage map also has to set the previous location.
There are two issues with how this is implemented in InsTrim:
In the InsTrim code the right shift of the prev_location is never performed.
e.g.
EntryBlock
/ | \
A B C
\ | /
ExitBlock
The writing to the map will happen in the ExitBlock, and the prev_location written will always be the ID of block A, and not depend on which actual path was taken.
In the code this is visible in the following line:
Two fix both issues, in afl++ we removed that CreateStore() and added after
IRB.CreateStore(Incr, MapPtrIdx);
:Note that this also needs a
ConstantInt *One32 = ConstantInt::get(Int32Ty, 1);
definition afterIntegerType *Int32Ty ...
The text was updated successfully, but these errors were encountered: