Skip to content

Add cmplog #37

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

Merged
merged 3 commits into from
May 13, 2025
Merged

Add cmplog #37

merged 3 commits into from
May 13, 2025

Conversation

Evian-Zhang
Copy link
Contributor

Thanks to LibAFL, the hardest part is already implemented. :)

@@ -265,6 +287,22 @@ where
}
}

/// Policy to deal with CMP and SUB instructions
pub enum CmpPolicy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't sound correct to me. Cmplog and Cmpcov can be used together, though might be not too effective. It should be bitflags in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's what the C-version of unicornafl does🤔

ERR("CMPLOG and CMPCOV turned on at the same time!\n");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@wtdcode wtdcode May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, then let us also do this way since using cmplog with cmpcov indeed doesn't have some interesting usages and cause slowdown.

A side question: can we even disable pc instrumentation when cmplog is detected? I forget a bit about cmplog details so correct me if that won't work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I'll check the implementation later.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed a new commit, which disables PC instrumentation for CMPLOG mode :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No please don’t. When compiling for cmplog some users compile only once and don’t mind the speed impact. And with this it would fail

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I need to update the docs to recommend doing this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about going to docs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warn!("I'll turn off CMPCOV.");
}
unsafe {
CMPLOG_ENABLED = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(not in the scope of this PR)

I do think we should avoid these global variables in libafl_targets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A practical way is do like what libafl_qemu's module system does. The map pointer is retrieved from passed-in map observers, but this only hide the global vars under the hood. Anyway, to real handle this problem, a lot of work in LibAFL still needs to be done (mostly in API design since the previous global var is parameter now)

@wtdcode wtdcode merged commit 80ce47e into AFLplusplus:v3 May 13, 2025
@wtdcode
Copy link
Member

wtdcode commented May 13, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants