From patchwork Wed Feb 28 21:06:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10249815 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 E378660212 for ; Wed, 28 Feb 2018 21:13:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2617286F1 for ; Wed, 28 Feb 2018 21:13:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6AED28DB3; Wed, 28 Feb 2018 21:13:47 +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 4493A286F1 for ; Wed, 28 Feb 2018 21:13:47 +0000 (UTC) Received: from localhost ([::1]:46957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er92o-0003cO-EV for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 16:13:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er8vu-0005iK-B5 for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:06:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er8vt-0000ZU-C1 for qemu-devel@nongnu.org; Wed, 28 Feb 2018 16:06:38 -0500 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:36947) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1er8vt-0000YR-4K; Wed, 28 Feb 2018 16:06:37 -0500 Received: by mail-lf0-x241.google.com with SMTP id y19so5627664lfd.4; Wed, 28 Feb 2018 13:06:37 -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=YRezYmLyRlf632XHYezdGfLcNqFX/xTISsphJnA5H7jNZe5TzK4gc/++XM7hNa69lh GQmkQgsuJFPEtE645Yohba1z27UQixaoBK954q521qlX0NUhjylqbwlI6wxD6xoaLGqN bqnMLDYAsCgo2tMmJNjA++sUskfSPFE6O08s0Qat3BHzuecHxHYAsXBmXmbdsjp7E8O6 qo3Gzt9AjQBZ/VAWGFIP1bA+aLz+fSzaZv+w1I/tVWjo7C4Eej05PqV/ojTXbKolDxNn fNv96STEnlnreQSgddGfSZHmBmjVfOsrW3hzOYLSqsiaR4EqqGgQfxjT+lywOWJ5U1Ck 9FXw== 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=GFxjMZ2UUacqHBSwT6R/4nt/fYZOEqxK1y3+rfoELQ+Xyuug9GknXUez1UyZoZOBJ+ TF8h6m94tI/zlM1pyVTHdoEpkqadEf1MjeI2AnPOJTyorCk3GuvPinb2cRZNLVzZF3kB WqMpiOTOYPXntn/5+JYODLo4PDJCiYBz5i3XAdvtEyAcc62jmnPjyVFY9778CyC3mn/z MYY7nO6YENt1DHgYIpDKylfAjmY49o2JpdZkarCmsT7WdGjb45Cst5SUuJRDVAot81b2 WJhy78r2ELjepl4JcH0uL+yAcACwJF+eE/R+DvAOR0EcLY3IMAWDqpcT/yN3Uga3k5lZ iHig== X-Gm-Message-State: APf1xPCOuC7tZ+j9XmV/51orTY/9vlRKeW2U3TGL7eCrRkT203IKoMva ZoUQokVqwrKVCd5/VTbX0tfIqw== X-Google-Smtp-Source: AG47ELtVPZdaxsFuMIu4fKASdaGqVwUj+st+9ZSe7TCgQczQQbe1OidGZgYeo7fOCN4vxVxRMCtofg== X-Received: by 10.46.51.17 with SMTP id d17mr10403309ljc.99.1519851995758; Wed, 28 Feb 2018 13:06:35 -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 l8sm547134lfb.19.2018.02.28.13.06.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 13:06:35 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 13:06:11 -0800 Message-Id: <20180228210616.2756-7-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180228210616.2756-1-jcmvbkbc@gmail.com> References: <20180228210616.2756-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 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 --- 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