From nobody Tue Apr 30 15:39:44 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 148732359578061.36391650204314; Fri, 17 Feb 2017 01:26:35 -0800 (PST) Received: from localhost ([::1]:52437 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceeoE-0005sB-Fp for importer@patchew.org; Fri, 17 Feb 2017 04:26:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ceeNF-0006NT-RC for qemu-devel@nongnu.org; Fri, 17 Feb 2017 03:58:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ceeNC-0001Vo-N0 for qemu-devel@nongnu.org; Fri, 17 Feb 2017 03:58:41 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:33559) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ceeNC-0001Ve-IG; Fri, 17 Feb 2017 03:58:38 -0500 Received: by mail-wr0-f194.google.com with SMTP id i10so4551786wrb.0; Fri, 17 Feb 2017 00:58:38 -0800 (PST) Received: from localhost.localdomain ([193.120.165.186]) by smtp.gmail.com with ESMTPSA id e74sm882027wmd.2.2017.02.17.00.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Feb 2017 00:58:36 -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=XB4JMXAD9VrAqVKqOyUVEjSG/E+KJGfk9aQSKwzQUfnrd/wGQGG41TfEty4HlbfnYr eg5xeBhEG2H5QJJPh6/yPIc7NXER1UEz1RPDYXv9sTGOMpomVwwLTTdhBqFK7YHZ/tIP 1FOd/DFuuWVYg2DZpfm3vgrlwkqiybQdNFp7vol0RQUWu2lVXBbCcRuIEmB6xHjztEEw pQmf0sG4wt/DMV03ciGrKssjw8/hnyZ81pHdxzfyTDTh5YVoEf6qVRUa1RIT0kGQixzw kQ0QeIyYFtuMaDkRtgX2tw3OD8vnvNdUl5lN0b6x22erOQGgRJ91Xqb9qrJJqJc2rhsO 5XLA== X-Gm-Message-State: AMke39lagjbC3sV6I/zXM0ci1TscXBYZxdYVz1WrACo9JfdNzGtIwGzoTL0sb+34P1mrfw== X-Received: by 10.223.139.220 with SMTP id w28mr5737761wra.172.1487321917300; Fri, 17 Feb 2017 00:58:37 -0800 (PST) From: Franklin Snaipe Mathieu To: qemu-devel@nongnu.org Date: Fri, 17 Feb 2017 08:58:00 +0000 Message-Id: <20170217085800.28873-2-snaipe@diacritic.io> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170217085800.28873-1-snaipe@diacritic.io> References: <20170216085857.23501-1-snaipe@diacritic.io> <20170217085800.28873-1-snaipe@diacritic.io> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.194 Subject: [Qemu-devel] [PATCH v2] 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 Reviewed-by: Laurent Vivier --- 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