gint flags; typelib_get_vma(this, &address, &oldsize); newsize = g_random_boolean() ? (PAGE_SIZE * 1) : (PAGE_SIZE * 2); flags = typelib_get_integer_mask(MREMAP_FIXED | MREMAP_MAYMOVE); // I don't currently handle MREMAP_FIXED. flags &= ~MREMAP_FIXED; retcode = syscall_fast_ret(&newaddr, __NR_mremap, // void * address, // void *old_address oldsize, // size_t old_size newsize, // size_t new_size flags, // int flags typelib_get_integer()); // unsigned long new_addr if (retcode == ESUCCESS) { // FIXME: Do something like this. // typelib_vma_moved(this, address, newaddr, newsize); typelib_vma_stale(this, address); typelib_vma_new(this, newaddr, newsize, VMA_NONE); } return retcode; }
#include "typelib.h" #include "iknowthis.h" // Map or unmap files or devices into memory. // void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset); SYSFUZZ(mmap, SYS_mmap, SYS_NONE, CLONE_DEFAULT, 0) { gintptr address; glong retcode; gsize size; size = typelib_get_integer(); retcode = syscall_fast_ret(&address, SYS_mmap, // void * typelib_get_integer(), // void *addr typelib_get_integer(), // size_t length size, // int prot typelib_get_integer(), // int flags typelib_get_resource(this, NULL, RES_FILE, RF_NONE), // int fd typelib_get_integer()); // off_t offset if (retcode == ESUCCESS) { // First, round size up to PAGE_SIZE size = (size + (PAGE_SIZE - 1)) & ~(PAGE_SIZE - 1); typelib_vma_new(this, address, size, 0); } return retcode; }