From nobody Tue Apr 30 03:42:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1487323417750711.1723501539713; Fri, 17 Feb 2017 01:23:37 -0800 (PST) Received: from localhost ([::1]:52411 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceelM-0003aD-Ht for importer@patchew.org; Fri, 17 Feb 2017 04:23:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceeN4-0006Cx-7y for qemu-devel@nongnu.org; Fri, 17 Feb 2017 03:58:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceeN0-0001Sv-TS for qemu-devel@nongnu.org; Fri, 17 Feb 2017 03:58:30 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36061) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceeN0-0001Sp-My; Fri, 17 Feb 2017 03:58:26 -0500 Received: by mail-wm0-f65.google.com with SMTP id r18so1369095wmd.3; Fri, 17 Feb 2017 00:58:26 -0800 (PST) Received: from localhost.localdomain ([193.120.165.186]) by smtp.gmail.com with ESMTPSA id e74sm882027wmd.2.2017.02.17.00.58.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 00:58:24 -0800 (PST) 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=E2VOJOSURVghvhgjYgW8cguq8gW+0fJLeryD4TKR3K0=; b=LwZlRH9nD2hshe4SISY8L6hX8X0SNd07lInh9cf6uzA60hCaKwH+yh135pap+hu/zl +aUCHGJrP6OcjTQM0ScQU4rZb4quI0oHVW2I4KpaMzWicX18nzu9BzwkKYtu5beWtjqE rL6Jgy8zwZN5UyOyK+exVEhuez9i6DM3lR/mIduSIITLrwUF9rxypF2g93sqi8PvqVbD FlT41CaMX3uLiNrGEG6zyZLyjoH+Iv7n3lLwGqXEc7u9whpL5QXSc7X8zb7dRVnO5rXt Mgri6O0IXpKH4t+3hIkvYIAWYLWmBWQ3BRpdIGJU2J4GgtoUU4Z+Y3W7owjmjPk1x5Ju 8Rcg== X-Gm-Message-State: AMke39kPkcGFUb97Vy7WsfsPLeAoKEJzgqsOnkvCLWN1LyPz1IkW74Y/pTJ3kQlUGIT3Ig== X-Received: by 10.28.68.6 with SMTP id r6mr2046608wma.57.1487321905169; Fri, 17 Feb 2017 00:58:25 -0800 (PST) From: Franklin Snaipe Mathieu To: qemu-devel@nongnu.org Date: Fri, 17 Feb 2017 08:57:59 +0000 Message-Id: <20170217085800.28873-1-snaipe@diacritic.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170216085857.23501-1-snaipe@diacritic.io> References: <20170216085857.23501-1-snaipe@diacritic.io> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 74.125.82.65 Subject: [Qemu-devel] [PATCH] syscall: fixed mincore(2) not failing with ENOMEM 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: qemu-trivial@nongnu.org, snaipe@arista.com, Riku Voipio , "Franklin \"Snaipe\" Mathieu" , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: "Franklin \"Snaipe\" Mathieu" The current implementation of the mincore(2) syscall sets errno to EFAULT when the region identified by the first two parameters is invalid. This goes against the man page specification, where mincore(2) should only fail with EFAULT when the third parameter is an invalid address; and fail with ENOMEM when the checked region does not point to mapped memory. Signed-off-by: Franklin "Snaipe" Mathieu Cc: Riku Voipio Cc: Aurelien Jarno --- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9be8e9530e..733e0009e1 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11061,11 +11061,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_l= ong arg1, case TARGET_NR_mincore: { void *a; + ret =3D -TARGET_ENOMEM; + a =3D lock_user(VERIFY_READ, arg1, arg2, 0); + if (!a) { + goto fail; + } ret =3D -TARGET_EFAULT; - if (!(a =3D lock_user(VERIFY_READ, arg1,arg2, 0))) - goto efault; - if (!(p =3D lock_user_string(arg3))) + p =3D lock_user_string(arg3); + if (!p) { goto mincore_fail; + } ret =3D get_errno(mincore(a, arg2, p)); unlock_user(p, arg3, ret); mincore_fail: --=20 2.11.0