Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

mprotect fails with Out of Memory #82

Open
angerman opened this issue Dec 26, 2018 · 2 comments
Open

mprotect fails with Out of Memory #82

angerman opened this issue Dec 26, 2018 · 2 comments

Comments

@angerman
Copy link

While trying to get my haskell executable to run, I've run into the following peculiar situation:

[51044:41097578] mmap(addr: 0x0000000000000000 [host: 0x0000000000000000], len: 0x16000, prot: 0, flags: 34, fd: -1, offset: 0x0): ret = 0xc0793000
[51044:41097578] mprotect(addr: 0x00000000c0794000 [host: 0x000000010efa1000], len: 0x15000, prot: 3): ret = 0xfffffffffffffff4[LINUX_ENOMEM]
[51044:41097578] munmap(gaddr: 0x00000000c0793000 [host: 0x000000010efa0000], size: 0x16000): ret = 0x0

This seems like it's a valid mprotect call to a mmaped region that was just returned with an offset of 0x1000.

However we fail with bfe00000 != c0794000 + 15000 in L261:

noah/src/mm/mmap.c

Lines 251 to 266 in b61c85c

while (region->gaddr + region->size <= end) {
hv_vm_protect(region->gaddr, region->size, hvprot);
mprotect(region->haddr, region->size, prot);
region->prot = hvprot;
if (region->list.next == &proc.mm->mm_regions) {
ret = -LINUX_ENOMEM;
goto out;
}
struct mm_region *next = list_entry(region->list.next, struct mm_region, list);
if (next->gaddr != region->gaddr + region->size) {
ret = -LINUX_ENOMEM;
goto out;
}
region = next;
}

@tommythorn
Copy link

tommythorn commented Jun 6, 2020

I forked https://github.com/johnothwolo/noah and reproduce this issue using test/testing_root/usr/bin/file. I don't know if this has regressed or if it ever worked, but it looks like this repo is dead and you have more luck with John's fork.

@johnothwolo
Copy link
Contributor

Could you link the program you were trying to run?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants