-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
Use const
to Inform CmpLog Replacements
#2528
Changes from 2 commits
b27bba5
96723b8
4d8ad3f
95d6685
87d1788
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 |
---|---|---|
|
@@ -47,6 +47,7 @@ typedef PACKED(struct CmpLogHeaderExtended { | |
typedef struct CmpLogInstruction { | ||
uint64_t v0; | ||
uint64_t v1; | ||
uint8_t v0_is_const; | ||
} CmpLogInstruction; | ||
|
||
typedef PACKED(struct CmpLogInstructionExtended { | ||
|
@@ -106,7 +107,8 @@ extern uint8_t libafl_cmplog_enabled; | |
// cmplog_routines_checked_extended | ||
|
||
static inline void cmplog_instructions_checked(uintptr_t k, uint8_t shape, | ||
uint64_t arg1, uint64_t arg2) { | ||
uint64_t arg1, uint64_t arg2, | ||
uint8_t arg1_is_const) { | ||
if (!libafl_cmplog_enabled) { return; } | ||
libafl_cmplog_enabled = false; | ||
|
||
|
@@ -126,6 +128,7 @@ static inline void cmplog_instructions_checked(uintptr_t k, uint8_t shape, | |
hits &= CMPLOG_MAP_H - 1; | ||
libafl_cmplog_map_ptr->vals.operands[k][hits].v0 = arg1; | ||
libafl_cmplog_map_ptr->vals.operands[k][hits].v1 = arg2; | ||
libafl_cmplog_map_ptr->vals.operands[k][hits].v0_is_const = arg1_is_const; | ||
libafl_cmplog_enabled = true; | ||
} | ||
|
||
|
@@ -152,6 +155,7 @@ static inline void cmplog_instructions_extended_checked( | |
hits &= CMPLOG_MAP_H - 1; | ||
libafl_cmplog_map_extended_ptr->vals.operands[k][hits].v0 = arg1; | ||
libafl_cmplog_map_extended_ptr->vals.operands[k][hits].v1 = arg2; | ||
libafl_cmplog_map_extended_ptr->vals.operands[k][hits].v0_is_const = 0; | ||
libafl_cmplog_map_extended_ptr->headers[k].attribute = attr; | ||
libafl_cmplog_enabled = true; | ||
#else | ||
|
@@ -186,6 +190,7 @@ static inline void cmplog_routines_checked(uintptr_t k, const uint8_t *ptr1, | |
hits &= CMPLOG_MAP_RTN_H - 1; | ||
MEMCPY(libafl_cmplog_map_ptr->vals.routines[k][hits].v0, ptr1, len); | ||
MEMCPY(libafl_cmplog_map_ptr->vals.routines[k][hits].v1, ptr2, len); | ||
libafl_cmplog_map_ptr->vals.operands[k][hits].v0_is_const = 0; | ||
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. this callback is for routines. you don't need it here 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. Again, this is basically an unused struct member - I still think it's worth making sure that it's initialised, even if it is always 0. 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. hmm but this is a union. so you shouldn't be touching operand side of this struct. 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. Good spot! |
||
libafl_cmplog_enabled = true; | ||
} | ||
|
||
|
@@ -214,6 +219,7 @@ static inline void cmplog_routines_checked_extended(uintptr_t k, | |
hits &= CMPLOG_MAP_RTN_H - 1; | ||
libafl_cmplog_map_extended_ptr->vals.routines[k][hits].v0_len = len; | ||
libafl_cmplog_map_extended_ptr->vals.routines[k][hits].v1_len = len; | ||
libafl_cmplog_map_extended_ptr->vals.operands[k][hits].v0_is_const = 0; | ||
MEMCPY(libafl_cmplog_map_extended_ptr->vals.routines[k][hits].v0, ptr1, len); | ||
MEMCPY(libafl_cmplog_map_extended_ptr->vals.routines[k][hits].v1, ptr2, len); | ||
libafl_cmplog_enabled = true; | ||
|
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 "extended" one is only used for llvm pass instrumentation (which is not using sancov stuff so you don't add it for this.
(but it's doable to add the const checking logic to the llvm pass
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.
line 222, too
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.
Yeah, hence it is set to
0
for now (unless you wanted to create a separateCmpLog
struct without thev0_is_const
member). I think that for longer comparisons (such as u64 or memcmps), the chance of conincidentally matching a const value is lower (apart from values like0
); so it's probably not worth the extra effort.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.
what i mean is
struct CmpLogInstructionExtended
doesn't have v0_is_const memberThere 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.
True