Skip to content
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

Make Launcher use ClientDescription instead of CoreId #2676

Merged
merged 66 commits into from
Nov 29, 2024

Conversation

riesentoaster
Copy link
Contributor

There may be more than one client running on each core, as per #2670.

The ClientId struct includes a reference to the CoreId, but has its own id that is unique for each client. Right now, this is independent of the LLMP ClientId, and I'm not sure I'm the right person to merge those, since I've never touched LLMP.

Also: I added overcommit to one of the example fuzzer as a (in the Makefile unused) command line arg, so users see that it exists.

@domenukk I didn't see you merged the other PR until I was already done with this…

riesentoaster and others added 6 commits November 9, 2024 23:19
* Replace addr_of with &raw across the codebase

* fix fixes

* more fix

* undo clang fmt?

* oops

* fix?

* allocator fix

* more fix

* more more

* more docs

* more fix

* mas mas mas

* hm

* more

* fix Frida

* needed

* more error

* qemu
* Trying to redo workspace deps again after AFLplusplus#2672

* unused

* clippy
* Replace addr_of with &raw across the codebase

* fix fixes

* more fix

* undo clang fmt?

* oops

* fix?

* allocator fix

* more fix

* more more

* more docs

* more fix

* mas mas mas

* hm

* more

* fix Frida

* needed

* more error

* qemu
* Trying to redo workspace deps again after AFLplusplus#2672

* unused

* clippy
@riesentoaster
Copy link
Contributor Author

riesentoaster commented Nov 10, 2024

I also noticed that the version fixing for the formatter in the CI was still broken, so I fixed it. That's why there are so many commits…

And so many other random little improvements.

@riesentoaster
Copy link
Contributor Author

Both remaining failing CI runs seem like they are timeouts, and they both work on my machine locally. I'm not sure why they start appearing and if we should increase the timeouts or otherwise do something to get them to behave more consistently.

@domenukk
Copy link
Member

We already have a ClientId that's used across the codebase, see:

pub struct ClientId(pub u32);

@domenukk
Copy link
Member

I think there are two ways:
a) Name the new dude CoreDescription or similar, indicating that it's just about what core we bind to
b) Merge the two and make sure the current ClientId (a unique ID assigned by the broker(!)) gets propagated correctly to this new struct. That'd be a neat solution, but migth be more involved.

@riesentoaster
Copy link
Contributor Author

What I would like is that the run_client function gets an additional id that uniquely identifies the client. After reading a bunch of the LLMP code, I think this is already present as the ClientId of the Sender.

  1. Is this assumption correct?
  2. Could I just extract this id and pass it to the function like so (last lines of Launcher::launch_with_hooks):
    let (state, mgr): (_, LlmpRestartingEventManager<_, _, _>) = builder.build().launch()?;
    let id = mgr.llmp_event_manager().llmp_client().sender().id();
    return (self.run_client.take().unwrap())(state, mgr, id, *bind_to);
    This would require the getters LlmpRestartingEventManager::llmp_event_manager and LlmpEventManager::llmp_client.
  3. One significant downside with this ClientId's internals being publicly accessible is that it is not obvious where it is created/fixed. So I'm not quite sure if it is already set correctly to its final value at this point. Do you happen to know if there are any guarantees about that?

@domenukk
Copy link
Member

Yeah that might just work, I think. But the idea about CoreId is that we can bind features like ASan to specific cores dynamically. So we would want CoreId, potentially the overcommit counter, and the unique sender ClientId.

@domenukk
Copy link
Member

For how CoreId is used right now, see:

#[arg(long, help = "Cpu cores to use for ASan", value_parser = Cores::from_cmdline)]

@riesentoaster
Copy link
Contributor Author

I'll try this in another branch, too many changes to revert. And I want to leave this here in case it's ever needed again.

@riesentoaster
Copy link
Contributor Author

@domenukk do you want to merge some form of this PR? Since there seems to be no consensus for your suggestion/PR #2684.

@riesentoaster
Copy link
Contributor Author

Alright, i've done the renaming. Not sure why the CI breaks.

@riesentoaster riesentoaster changed the title Make Launcher use ClientId instead of CoreId Make Launcher use ClientDescription instead of CoreId Nov 22, 2024
@riesentoaster
Copy link
Contributor Author

Not sure why the CI breaks.

Ah, #2715

Copy link
Contributor Author

@riesentoaster riesentoaster left a comment

Choose a reason for hiding this comment

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

Anyone know why launcher compared cores to enumerator values instead of the actual cores? I changed it, but don't know if there is a reason behind it. Just seemed odd.

Old version (example):

for (id, bind_to) in core_ids.iter().enumerate() {
    if self.cores.ids.iter().any(|&x| x == id.into()) {

Comment on lines +275 to +276
for bind_to in core_ids {
if self.cores.ids.iter().any(|&x| x == bind_to) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Occurrence 1

Comment on lines +451 to +452
for core_id in core_ids {
if self.cores.ids.iter().any(|&x| x == core_id) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Occurrence 2

Comment on lines +732 to +733
for bind_to in core_ids {
if self.cores.ids.iter().any(|&x| x == bind_to) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Occurrence 3

@riesentoaster
Copy link
Contributor Author

@domenukk opinions? On the above and generally this PR?

Or who do I ask?

@@ -12,66 +12,52 @@
//! On `Unix` systems, the [`Launcher`] will use `fork` if the `fork` feature is used for `LibAFL`.
//! Else, it will start subsequent nodes with the same commandline, and will set special `env` variables accordingly.

use alloc::string::ToString;
#[cfg(feature = "std")]
Copy link
Member

Choose a reason for hiding this comment

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

thanks for deleting this

@tokatoka
Copy link
Member

Anyone know why launcher compared cores to enumerator values instead of the actual cores?

No idea.

but it should be the same as it is iterating over what core id cpus have. but it's better with your change

@tokatoka
Copy link
Member

yeah looks good

@tokatoka tokatoka merged commit bdde109 into AFLplusplus:main Nov 29, 2024
102 of 103 checks passed
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.