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

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

Closed
stickycookie opened this issue Aug 20, 2024 · 2 comments
Closed

Comments

@stickycookie
Copy link

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

@stickycookie
Copy link
Author

update poc

backend.mem_map(0, 0x100000, 0);
backend.mem_protect(0, 0x2000, 3);

@stickycookie
Copy link
Author

fixed in #663

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

No branches or pull requests

1 participant