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

Commit 1434bc5

Browse files
committed
Fix shmat() to work correctly
shmat() maps the memory region without executable permission by default, while Noah tries to map the region onto the VM with executable permission, and it fails. It also incorrectly returns the host address instead of the guest address.
1 parent 9468dcf commit 1434bc5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/mm/shm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ DEFINE_SYSCALL(shmat, int, shmid, gaddr_t, addr, int, shmflg)
4848
pthread_rwlock_wrlock(&proc.mm->alloc_lock);
4949
addr = alloc_region(len);
5050
do_munmap(addr, len);
51-
record_region(proc.mm, ptr, addr, len, LINUX_PROT_READ | LINUX_PROT_WRITE | LINUX_PROT_EXEC, LINUX_MAP_PRIVATE | LINUX_MAP_FIXED, -1, 0);
52-
vmm_mmap(addr, len, HV_MEMORY_READ | HV_MEMORY_WRITE | HV_MEMORY_EXEC, ptr);
51+
record_region(proc.mm, ptr, addr, len, LINUX_PROT_READ | LINUX_PROT_WRITE, LINUX_MAP_PRIVATE | LINUX_MAP_FIXED, -1, 0);
52+
vmm_mmap(addr, len, HV_MEMORY_READ | HV_MEMORY_WRITE, ptr);
5353
pthread_rwlock_unlock(&proc.mm->alloc_lock);
54-
return (uint64_t) ptr;
54+
return (uint64_t) addr;
5555
}
5656

5757
DEFINE_SYSCALL(shmctl, int, shmid, int, cmd, gaddr_t, buf_ptr)

0 commit comments

Comments
 (0)