Skip to content

Fixed memory limit bypass using mremap #42

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

Closed
wants to merge 1 commit into from

Conversation

mikimasn
Copy link
Contributor

@mikimasn mikimasn commented Feb 1, 2024

Due to MemoryLimitListener only validating memory usage on mmap it was possible to use mremap to bypass memory limit.

@mikimasn mikimasn closed this Feb 1, 2024
@Wolf480pl
Copy link
Member

Wolf480pl commented Feb 6, 2024

Have you managed to actually bypass memory limit with it?

AFAIU your VmPeak would still exceed the limit after your program exits, so sio2jail would count that as MLE.
The only concern is that a big mremap could file due to the rlimit, so unless the program handles memory allocation failure correctly (most programs don't), it'd result in a different error (most likely segfault, abort, or non-zero exit, possibly also wrong answer) that wouldn't communicate that the memory limit was the root cause, which could cause confusion.

Your PR didn't look quite right, but I think the overall direction was good.
I can review it and give you a detailed feedback, if you want to continue working on it. I think after some small improvements this could be merged.

Also, why did you close it?

@mikimasn
Copy link
Contributor Author

mikimasn commented Feb 6, 2024

I closed it because I didn't bypass the memory limit.

I assumed there exists a default memory limit because my attempt to simply mmap table with size 1e7 failed with memory limit exceeded but an attempt to mmap with size 1e6 succeeded. About 20 minutes after submitting the PR I realized my mistake and decided to close the PR because it was invalid.

I would like to continue with PR(but under another, valid name) and fix a bug that at the beginning resulted in a memory limit exceeded error while running my program without any memory limit.

@mikimasn
Copy link
Contributor Author

mikimasn commented Feb 6, 2024

I opened new PR #43

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.

2 participants