Skip to content
Snippets Groups Projects
Commit ceda5688 authored by Richard Henderson's avatar Richard Henderson
Browse files

linux-user: Fix shmdt


If the shm region is not mapped at shmaddr, EINVAL.
Do not unmap the region until the syscall succeeds.
Use mmap_reserve_or_unmap to preserve reserved_va semantics.

Tested-by: default avatarHelge Deller <deller@gmx.de>
Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
parent 69fa2708
No related branches found
No related tags found
No related merge requests found
......@@ -1102,14 +1102,25 @@ abi_long target_shmdt(abi_ulong shmaddr)
/* shmdt pointers are always untagged */
WITH_MMAP_LOCK_GUARD() {
for (int i = 0; i < N_SHM_REGIONS; ++i) {
int i;
for (i = 0; i < N_SHM_REGIONS; ++i) {
if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) {
shm_regions[i].in_use = false;
page_set_flags(shmaddr, shmaddr + shm_regions[i].size - 1, 0);
break;
}
}
if (i == N_SHM_REGIONS) {
return -TARGET_EINVAL;
}
rv = get_errno(shmdt(g2h_untagged(shmaddr)));
if (rv == 0) {
abi_ulong size = shm_regions[i].size;
shm_regions[i].in_use = false;
page_set_flags(shmaddr, shmaddr + size - 1, 0);
mmap_reserve_or_unmap(shmaddr, size);
}
}
return rv;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment