From patchwork Tue Jun 19 01:41:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 931280 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="pS3EJ3R+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 418sH60Mj8z9s37 for ; Tue, 19 Jun 2018 12:24:34 +1000 (AEST) Received: from localhost ([::1]:38599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV6Jr-0005pO-MD for incoming@patchwork.ozlabs.org; Mon, 18 Jun 2018 22:24:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fV5hY-00018O-UT for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fV5hY-00087W-1f for qemu-devel@nongnu.org; Mon, 18 Jun 2018 21:44:57 -0400 Received: from mail-oi0-x242.google.com ([2607:f8b0:4003:c06::242]:33342) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fV5hX-00087P-ST; Mon, 18 Jun 2018 21:44:55 -0400 Received: by mail-oi0-x242.google.com with SMTP id c6-v6so16698615oiy.0; Mon, 18 Jun 2018 18:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=kqyIMwNa5Ip7nhkfm8ERV6p+wMvHFWzhC2yEGIitDg8=; b=pS3EJ3R+DIheOGNOMM+TcXM4zL4db1hmJ1qJlPYB08aQNG1CGMwypFwjY9PBZz7NXZ KDDR+/8tolW5g1GJJ6IaVhyWuntNYBUrnNpxbQzVWAILyVLIjTWw682W07SphZhRurFx o+5cNeC0676xyfPV0j8docqRaeANyLhDgpzgmR+6s5IKU1/VZ7XqFodm/w8aMTgyTKba ukIrLKGyM4zwInwT2mlTOrWqtaY8pIDmTyQKOe9ZKjK0vLGW0D1L1YB0Z5amYlN+4Tgl 71DhO34YzL+SV1GqaYrU2TSI2qmuhNIHVIOBlJ58cQ76m13jEH1CovElixbag65xY5Nb ggbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=kqyIMwNa5Ip7nhkfm8ERV6p+wMvHFWzhC2yEGIitDg8=; b=eliq44oQKh0XJNzfAjUDWrSX/OyPTb7XuCYR0lQIw5Ka7f7VItyBF8U8fryNQWp6F+ KR5UljJYR9UvsUr58R19R6GSAPvf+iL/AMPJO/IXBa7gFi/FAlMKBGO9K2kUSvVsSaN7 httkVFtLFz87cIsnfsxwHNC9tpMFW9z8W5Evd0t1AZFxI9Blp/qmLu1m9RRZLKYcTony 2CW1nZ9GXPb3h6fgaBtxYIbibSj2WnIBk2xIDJLaNsbQlauk7AW0D+rvx5pUvDq51mZq jeSVzdelT8yKNMhA5Wt5N7TWidYXfaLfm28ZK7ioOlyiZdySFvgbP64mqam2VePp3MNP 4NZQ== X-Gm-Message-State: APt69E34wavDLOqbp/gc+f8zDz7Z2OXyfMVgg6ua1gfMSqLvWEa5KPRK 1/Yqb1s0gKV2xZ0Qz2b4/UrNyo6s X-Google-Smtp-Source: ADUXVKLomTbnjsArUf3CFBuWhUqcS0ozCpKsylaHXmGGpytQBz0TAarNAwDSyMw8rAd15ZmFTOP3mQ== X-Received: by 2002:aca:cc4a:: with SMTP id c71-v6mr8805836oig.152.1529372694709; Mon, 18 Jun 2018 18:44:54 -0700 (PDT) Received: from localhost ([2600:1700:70:e488:b0ee:9bda:ee6f:91be]) by smtp.gmail.com with ESMTPSA id c17-v6sm7363271otl.17.2018.06.18.18.44.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Jun 2018 18:44:53 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 20:41:50 -0500 Message-Id: <20180619014319.28272-25-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> References: <20180619014319.28272-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::242 Subject: [Qemu-devel] [PATCH 024/113] linux-user: fix assertion in shmdt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Max Filippov , Riku Voipio , qemu-stable@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov 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 --- linux-user/syscall.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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