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

Randomize zones granularity #49

Open
jvoisin opened this issue Sep 25, 2021 · 3 comments
Open

Randomize zones granularity #49

jvoisin opened this issue Sep 25, 2021 · 3 comments

Comments

@jvoisin
Copy link
Contributor

jvoisin commented Sep 25, 2021

Currently, isoalloc has zones in increasing power of two, for performance reasons.

Unfortunately, this means that an attacker aiming at exploiting an UAF against an object of size N only needs to find an object of size between the previous and the next power of two, to be able to get it allocated with reasonable confidence (quarantine notwithstanding).

Introducing a bit of randomness in the granularity will make the life of an attacker without the ability to leak too much data a bit harder, since they would have no way to be sure that they managed to allocate the object of their choosing in the same zone as the freed-and-to-be-reused object.

@struct
Copy link
Owner

struct commented Dec 17, 2023

Chunk sizes are no longer powers of 2 after #216, they are now multiples of 64. I think the scenario you described above is less likely now but still possible.

@jvoisin
Copy link
Contributor Author

jvoisin commented Dec 17, 2023

>>> import itertools
>>> len(list(itertools.takewhile(lambda x: x<4096, (64*i for i in itertools.count(0)))))
64
>>> len(list(itertools.takewhile(lambda x: x<4096, (2**i for i in itertools.count(0)))))
12
>>> 

this indeed significantely increases granularity, nice!

But wouldn't it increase memory fragmentation as well?

@struct
Copy link
Owner

struct commented Dec 17, 2023

Yes. I don't think theres an optimum general solution here. It's full of tradeoffs all the way down.

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