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

mprotect fails with Out of Memory #82

Open

Description

@angerman

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;
}

Activity

  1. tommythorn commented on Jun 6, 2020

    @tommythorn

    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.

  2. johnothwolo commented on Jun 9, 2020

    @johnothwolo
    Contributor

    Could you link the program you were trying to run?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions