From: Max Filippov Date: Wed, 28 Feb 2018 22:16:04 +0000 (-0800) Subject: linux-user: fix assertion in shmdt X-Git-Tag: qemu-xen-4.11.1^2~99 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=8fc971ed1b44f7910a5ee928acccb3a70156c237;p=qemu-xen.git linux-user: fix assertion in shmdt shmdt fails to call mmap_lock/mmap_unlock around page_set_flags, resulting in the following assertion: page_set_flags: Assertion `have_mmap_lock()' failed. Wrap shmdt internals into mmap_lock/mmap_unlock. Cc: qemu-stable@nongnu.org Cc: Riku Voipio Cc: Laurent Vivier Signed-off-by: Max Filippov Reviewed-by: Laurent Vivier Message-Id: <20180228221609.11265-7-jcmvbkbc@gmail.com> Signed-off-by: Laurent Vivier (cherry picked from commit 3c5f6a5f888729f9fbc64211298f7c3e2fb42b64) Signed-off-by: Michael Roth --- diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9872de7221..74d56e2ee6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4918,6 +4918,9 @@ static inline abi_ulong do_shmat(CPUArchState *cpu_env, static inline abi_long do_shmdt(abi_ulong shmaddr) { int i; + abi_long rv; + + mmap_lock(); for (i = 0; i < N_SHM_REGIONS; ++i) { if (shm_regions[i].in_use && shm_regions[i].start == shmaddr) { @@ -4926,8 +4929,11 @@ static inline abi_long do_shmdt(abi_ulong shmaddr) break; } } + rv = get_errno(shmdt(g2h(shmaddr))); + + mmap_unlock(); - return get_errno(shmdt(g2h(shmaddr))); + return rv; } #ifdef TARGET_NR_ipc