From patchwork Wed Feb 28 22:16:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10249979 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1815460362 for ; Wed, 28 Feb 2018 22:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F156728A67 for ; Wed, 28 Feb 2018 22:18:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5F7328B5A; Wed, 28 Feb 2018 22:18:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2469528B38 for ; Wed, 28 Feb 2018 22:18:26 +0000 (UTC) Received: from localhost ([::1]:47323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erA3N-0004vn-Ad for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 17:18:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54448) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erA1g-0003Lb-C7 for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:16:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erA1b-0003JN-RH for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:16:40 -0500 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:37408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1erA1b-0003HS-Ed; Wed, 28 Feb 2018 17:16:35 -0500 Received: by mail-lf0-x241.google.com with SMTP id y19so5879638lfd.4; Wed, 28 Feb 2018 14:16:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mN9uP3ViiMufF3xuAxqZlaEhTqcuM/v/6Zil1g/KPYM=; b=itSrKVvIAqnGf6HIY0XzjNss5I5tkd2MrTvFH6UYeY6+wIf4eakZK0mz/4iiXwrCnM GB+/kbY7v1i/qgrc6OSDxYMQexTd1+bvlEiOqRuAC6xzwyKN3RhnnhTBnzx4G7pJirQl uyNig1lNxEstbkQiFL2/JSrYq8ksX1De9QDeb3ue4UfLmPU9OYFIoXkFjXyJ53+cfn3o AYusx1TiFRqVPDNuoYeaX0GO66a+4KzwuTe2ylX5rr7Ac2FsHw1XxKswDxXxFuonyAbt uk6rBWTXQVZ9c+oOu3evddXHzknQOyUMBQqCbUVcMWmJmlFKgh/9duN3ZDByoOdpvw/O 53hQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mN9uP3ViiMufF3xuAxqZlaEhTqcuM/v/6Zil1g/KPYM=; b=HXdm+mJo9btggTCKhIBRuuaBakPvXljEslltQv51kqItboVJKBsq/jGIDEMaQPxq7F AgIunghfLwK9bnIL0jlFDRdYRaBe1iW3q7X/7wMb+jmZpj1zBqy4XH6ryGDSPUorFKM2 5Pvzh3hrQyHwVCHYqXiJf+XEWK3ErIiQLc2j9ySISMcGXC1erMBs/w2HYy20K0c0cUiC fKFIFKDoyvj9a5DM/cdFJkMiqM8O5Dq+ylmvyrXsrRqoFt89JQzNRs3DJauqRPNsAJMY ieK5lkgt9NxtV22nMC/SrpA8CAxNFob3YqFB3tdstyd//HCLe8W/YkRxZH0I0BT6MwZs 8U+w== X-Gm-Message-State: APf1xPBhftVTCeWPsAqpLGyQrneyKpl0YU8MpRfAjx/CoqCZPCkr17C2 hd0CAsYe+f0qnWOF68Yct6xtTQ== X-Google-Smtp-Source: AG47ELs4xgi3fpJcf7plx5MbgEOjvGm53qdAr1BwbwfKcfvXz2FpQTR8VwLzi5HSzJBS0MjyFYihmQ== X-Received: by 10.25.198.23 with SMTP id w23mr13647020lff.40.1519856194095; Wed, 28 Feb 2018 14:16:34 -0800 (PST) Received: from octofox.cadence.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id s82sm566984lja.7.2018.02.28.14.16.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 14:16:33 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 14:16:04 -0800 Message-Id: <20180228221609.11265-7-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180228221609.11265-1-jcmvbkbc@gmail.com> References: <20180228221609.11265-1-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::241 Subject: [Qemu-devel] [PATCH v2 06/11] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 79245e73784f..595b26fdd8f3 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4947,6 +4947,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) { @@ -4955,8 +4958,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