From patchwork Wed Feb 28 22:16:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10249989 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 18C8E60362 for ; Wed, 28 Feb 2018 22:21:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F211B28A80 for ; Wed, 28 Feb 2018 22:21:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4ABB28E57; Wed, 28 Feb 2018 22:21:28 +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 61A8928A80 for ; Wed, 28 Feb 2018 22:21:28 +0000 (UTC) Received: from localhost ([::1]:47343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erA6J-0007Sp-IV for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Feb 2018 17:21:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erA1j-0003OZ-K9 for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:16:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erA1e-0003NG-KY for qemu-devel@nongnu.org; Wed, 28 Feb 2018 17:16:43 -0500 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]:36677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1erA1e-0003LR-7o; Wed, 28 Feb 2018 17:16:38 -0500 Received: by mail-lf0-x241.google.com with SMTP id g72so5885012lfg.3; Wed, 28 Feb 2018 14:16:38 -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=f0UAVJcUDq2ABjMeysWuqgBuFlb2SfgmwZQ7VJ5CUAM=; b=it8yaJRPiMBEkaveTlhBHULLNS+mMocxcsheXrtV4KsUwT4pTCFwPfd94EV4U9tGoA f7/bISdPAVW5i9wlR6xnmwIcofr+yHXYIZ7LqlqukUVoYQLc5XQrwWuhCDki18b10H3a G15pvLxtgz4sWoJJU4bqI2H73zaitINJjC7yULAQYEPE8AL2TKuoRWigjy/ex2Rol2zl Al5a40UBRJGvUZfcZ7jO35OZh3Vdq6ivEfNV7e6ihlwXXpj0fLkCOL88wMCrdY41Wt6f YZqSDwipUIm03geQ9vBb/5Zx5i4hdwV8RuZFwhlYP9q4SNbfA7mvK/5VYkSn7kNRifEl lp1A== 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=f0UAVJcUDq2ABjMeysWuqgBuFlb2SfgmwZQ7VJ5CUAM=; b=d7G+PU21sIAJnnT5asw1up/9YL+6FbsxubhTCf8vo3dRA/vo5x48XIYBvV4IsMUa8e ac0Thc+8lwmUi9v3pvxzJfBjlpv7qMJab1QkAukHV6yp8//PzNvhgM8FUTr9xk4Dgc+I delloKStQ9lDIqLbrqfLp6u1zBDx9wLfhadgiRsooPPcNdtNMUgYo0kJWHPbjpB4gZ3j puXJrNhI/dnbYC6+vVvRWMtOdJkeTecYdlvLw0q63nhcEZQRlznKgktM3R25ZxwlUhUd B1Ts2JY/sX8HDOeXvleRZy8hM7nDSMQpgu26MPjfIBd5740dKNasFDiXTB7Msv3zvacA zVBw== X-Gm-Message-State: APf1xPA1wSzpeWCFhnW+j7XPYUFoAJ/TQYf0Rg1GU/NP13VVS3EpWEhW dHK5B/3z1BDUni1S/wPewIgE0A== X-Google-Smtp-Source: AG47ELsf9o02jBmfqHFxxVMq0N+F4HuhbIdhdh7jAEw3SJcKVw7ApC89memjw0Otku4yWLkn3YNVUQ== X-Received: by 10.25.103.20 with SMTP id b20mr13932880lfc.16.1519856196831; Wed, 28 Feb 2018 14:16:36 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Feb 2018 14:16:36 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 14:16:05 -0800 Message-Id: <20180228221609.11265-8-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 07/11] linux-user: fix target_mprotect/target_munmap error return values 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 target_mprotect/target_munmap return value goes through get_errno at the call site, thus the functions must either set errno to host error code and return -1 or return negative guest error code. Do the latter. Cc: qemu-stable@nongnu.org Cc: Riku Voipio Cc: Laurent Vivier Signed-off-by: Max Filippov Reviewed-by: Laurent Vivier --- linux-user/mmap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index df81f9b803b6..84b15c9a1699 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -77,11 +77,11 @@ int target_mprotect(abi_ulong start, abi_ulong len, int prot) #endif if ((start & ~TARGET_PAGE_MASK) != 0) - return -EINVAL; + return -TARGET_EINVAL; len = TARGET_PAGE_ALIGN(len); end = start + len; if (!guest_range_valid(start, len)) { - return -ENOMEM; + return -TARGET_ENOMEM; } prot &= PROT_READ | PROT_WRITE | PROT_EXEC; if (len == 0) @@ -621,10 +621,10 @@ int target_munmap(abi_ulong start, abi_ulong len) start, len); #endif if (start & ~TARGET_PAGE_MASK) - return -EINVAL; + return -TARGET_EINVAL; len = TARGET_PAGE_ALIGN(len); if (len == 0 || !guest_range_valid(start, len)) { - return -EINVAL; + return -TARGET_EINVAL; } mmap_lock();