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

Chore(mmu): add overflow handling #452

Merged
merged 12 commits into from
Nov 4, 2024

Conversation

4rgon4ut
Copy link
Contributor

@4rgon4ut 4rgon4ut commented Sep 12, 2024

This PR add additional memory overflow detection(for both stack and heap).

Added:

  • function to assert memory region where:
    1. zero padding region => stack overflow
    2. address higher than memory array length => heap overflow
    3. other not expected region => unknown mapping panic
  • unit tests
  • example to trigger stack && heap overflow in runtime

Closes: #395

@4rgon4ut
Copy link
Contributor Author

4rgon4ut commented Sep 12, 2024

I feel I need to get an acknowledgement for my direction as Im new to the codebase @moodlezoup.

  1. Memory model:
image

Thus every attempt to write to zero_padding addresses is stack overflow and all writes over DRAM_BASE + memory.capacity is heap overflow. Is that correct?

  1. It would be also nice to have sort of example program to face this cases in runtime. Is that something you would like to see?

  2. store_raw() have no tracer call before actual operation, should I add checks in *_raw() functions?

@moodlezoup
Copy link
Collaborator

I feel I need to get an acknowledgement for my direction as Im new to the codebase @moodlezoup.

  1. Memory model:
image Thus every attempt to write to `zero_padding` addresses is stack overflow and all writes over `DRAM_BASE + memory.capacity` is heap overflow. Is that correct?

Yes this is correct

  1. It would be also nice to have sort of example program to face this cases in runtime. Is that something you would like to see?

Yes, it would be great to have a test for this feature

  1. store_raw() have no tracer call before actual operation, should I add checks in *_raw() functions?

I think so, but I haven't looked at that code in a while so if there's a better place to add the checks, go ahead

@4rgon4ut 4rgon4ut force-pushed the chore/add-overflow-handling branch from f63f5a6 to ee22f69 Compare October 23, 2024 08:17
@4rgon4ut 4rgon4ut marked this pull request as ready for review October 23, 2024 18:46
@4rgon4ut 4rgon4ut force-pushed the chore/add-overflow-handling branch from 00b6e77 to 62dc80f Compare October 24, 2024 14:42
@4rgon4ut
Copy link
Contributor Author

@moodlezoup

@4rgon4ut 4rgon4ut force-pushed the chore/add-overflow-handling branch from 62dc80f to 6a3dda2 Compare October 31, 2024 18:55
@4rgon4ut 4rgon4ut force-pushed the chore/add-overflow-handling branch from cc13834 to 6828beb Compare November 1, 2024 18:43
Copy link
Collaborator

@moodlezoup moodlezoup left a comment

Choose a reason for hiding this comment

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

Really nice work, thanks for adding the test cases!

@moodlezoup moodlezoup merged commit 3b14242 into a16z:main Nov 4, 2024
6 checks passed
@4rgon4ut 4rgon4ut deleted the chore/add-overflow-handling branch November 5, 2024 09:25
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.

Better errors for insufficient stack or memory size
2 participants