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

Incorrect node type casting in libafl_maps_next leads to out-of-bound dereference #46

Closed
cube0x8 opened this issue Feb 5, 2024 · 2 comments

Comments

@cube0x8
Copy link
Contributor

cube0x8 commented Feb 5, 2024

The libafl_maps_next function casts an IntervalTreeNode to a MapInfo using the container_of macro (13685). However, the root of the interval tree is initialized as IntervalTreeRoot in the read_self_maps function (23). This mismatch in types leads to an out-of-bound dereference when accessing e->itree.start in libafl_maps_next (13687).

This is definitely a minor bug since h2g_valid is likely to return always false, but still is blocking me to debug QEMU using ASAN.

I assign this to me, but suggestions on how to fix it are very welcome. Here my proposals:

  1. Somewhat, make root a MapInfo instead of IntervalTreeRoot, but maybe this would require changes in the interval tree implementation in QEMU, so I don't think it's a good idea.
  2. Use a boolean flag in libafl_maps_next when called the first time (maybe too ugly)
@andreafioraldi
Copy link
Member

andreafioraldi commented Feb 5, 2024 via email

@cube0x8 cube0x8 closed this as completed Feb 7, 2024
@cube0x8 cube0x8 reopened this Mar 13, 2024
@cube0x8
Copy link
Contributor Author

cube0x8 commented Mar 13, 2024

Yes, instead of fixing it, I broke it even more. I'm reopening this because it's something I want to fix once we're done with #52.

@cube0x8 cube0x8 closed this as completed Apr 12, 2024
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

No branches or pull requests

2 participants