linux-user: Don't assert if guest tries shmdt(0)
commitb6e17875f2e4d1ebfd45bcb0eed04c3157e86a84
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 9 Feb 2016 15:57:11 +0000 (9 15:57 +0000)
committerRiku Voipio <riku.voipio@linaro.org>
Tue, 23 Feb 2016 19:25:09 +0000 (23 21:25 +0200)
treef88b68b7f8d1c4bddac4547cd2b2f2b078265343
parentde3f1b98410e0d5b406a0df3a48547b559d18602
linux-user: Don't assert if guest tries shmdt(0)

Our implementation of shmat() and shmdt() for linux-user was
using "zero guest address" as its marker for "entry in the
shm_regions[] array is not in use". This meant that if the
guest did a shmdt(0) we would match on an unused array entry
and call page_set_flags() with both start and end addresses zero,
which causes an assertion failure.

Use an explicit in_use flag to manage the shm_regions[] array,
so that we avoid this problem.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reported-by: Pavel Shamis <pasharesearch@gmail.com>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c