Skip to content

UC_ERR_NOMEM, backend fails to use mem_protect after using vm.loadLibrary #662

@stickycookie

Description

@stickycookie

I tried this poc on 4e75367
And it seems like error occurs when using mem_map with more than 0x100000 size after calling the vm.loadLibrary.
poc is here:

public static void main(String[] args)
{
    emulator = AndroidEmulatorBuilder
            .for64Bit()
            .addBackendFactory(new Unicorn2Factory(true))
            .setProcessName("bugpoc")
            .setRootDir(new File("unidbg-android/src/test/resources/VFS"))
            .build();

    Memory memory = emulator.getMemory();
    memory.setLibraryResolver(new AndroidResolver(26));
    vm = emulator.createDalvikVM();
    vm.setVerbose(true);
    vm.loadLibrary(new File("unidbg-master\\unidbg-android\\target\\classes\\android\\sdk23\\lib64\\libc.so"),false);

    Backend backend = emulator.getBackend();
    backend.mem_map(0x20f000, 0x101000, 0);
    backend.mem_protect(0x20f000, 0x2000, 3);
}

the error message is
Exception in thread "main" com.github.unidbg.arm.backend.BackendException: mem_protect address=0x20f000, size=8192, perms=0x3 at com.github.unidbg.arm.backend.Unicorn2Backend.mem_protect(Unicorn2Backend.java:147) at com.test.BugPoc.main(BugPoc.java:70) Caused by: unicorn.UnicornException: No memory available or memory not present (UC_ERR_NOMEM) at com.github.unidbg.arm.backend.unicorn.Unicorn.mem_protect(Native Method) at com.github.unidbg.arm.backend.unicorn.Unicorn.mem_protect(Unicorn.java:249) at com.github.unidbg.arm.backend.Unicorn2Backend.mem_protect(Unicorn2Backend.java:145) ... 1 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions