From patchwork Thu Mar 7 10:06:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 1052773 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=vivier.eu Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44FRLn0H0Hz9sB3 for ; Thu, 7 Mar 2019 21:14:25 +1100 (AEDT) Received: from localhost ([127.0.0.1]:48561 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1q2h-0001Sv-07 for incoming@patchwork.ozlabs.org; Thu, 07 Mar 2019 05:14:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1pvo-00042k-2k for qemu-devel@nongnu.org; Thu, 07 Mar 2019 05:07:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1pvn-0007Tf-2d for qemu-devel@nongnu.org; Thu, 07 Mar 2019 05:07:16 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:43573) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1pvm-0007St-FC for qemu-devel@nongnu.org; Thu, 07 Mar 2019 05:07:14 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MhUHt-1gXkF80Z4F-00eZ65; Thu, 07 Mar 2019 11:07:05 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 11:06:53 +0100 Message-Id: <20190307100656.14044-7-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190307100656.14044-1-laurent@vivier.eu> References: <20190307100656.14044-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:Ll8SPn9rVdRcjLtfXyaBzZPomvclVxJExdlLly+1xkSUS12T8eO TQnBgGEbQytqFOKIpbI1e7/6E1/nrPbH1TwmosEJL6rxjf65elPUiv9ePoLc/fKXxYEYuxg IQ0UVR4XDmNYs1GFL7fyDLGoDiS5XiWuQKfu0QTkiSVyd4ftJ5RGiTnj3FrAnXuX/Zb0TDb 9+LRD+bPSyJQHN1wk4IiA== X-UI-Out-Filterresults: notjunk:1; V03:K0:djpBqkc7NRk=:T4/X1Q/v4I8oY10q7UaAia ACuZGlFyRZpXj2kyxjuAWFKpxKWJgkIMuJXsycgmoN//TXlsNBCEQnaqoVJeBrm9De56x1kGJ Bnv6OBDLCR+stpylf1dOZ/sDgpoLDj+EvWYwACye7TeqWFUt+Hsa5laqSNDTnSFuSL4HWYlOx 5agZ9W4t3KE9O/XmcpecQMND6CUo2jnYKaAeoqXahRNyN35PVTBzmVkCJSxCiVejw5Mrr4d2x 9mCheOiR9iwABzyWydZrLazp0+ZrBraiOSYeQqgElV0NEORDzaOMFPAzFSNoR0AfS8zqZZ4mk snAMQtbyHFWrc5Wh13Vd30riosvqvDkWHcYe37Dvn4TJq9QSiO+FHSSk0UDCuI2oVGlP3ZX7d tqVUYz6gaZXbsESZiRIsBXkdJzVWSrsn1/LwN6W2SuVM/3d0hZc0DPXM6FHDQxrPoI7svu4dk 8GQxJ+XdQcDDM5TCC93pqC866XdiqyOJaCUPkbgSZWm6tP8OTvsRlwHaLF1PVcaeXopCxqGt8 VePPHIX8Vkp/Tc4f86MU6/evxRMSDXjcLcbRmhmPt2eNWSjNIFOW1dFrsaCo8jIpLUcWSeXom m3xHOqTz9U+Aa0OVz1zx1qt3hL/+zUx2xHMJDpu3rwKYFECCwJqvMDH3xqaPQJacSiSezgWGE NDhmxi1ZkwgcojKic0Gifx4n/W8ZwX+EBOczUdBfsUmiU2aCOYOjF7RRjOa6Cv1uAhoJjrmQ1 AzxJasnFhc/1a4wNnhbKW7y1rOVHsvHNDrPNVA== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 217.72.192.73 Subject: [Qemu-devel] [PULL 6/9] linux-user: don't short-circuit read with zero length 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: Andreas Schwab , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Andreas Schwab A zero-length read still needs to do the usual checks, thus it may return errors like EBADF. This makes the read syscall emulation consistent with the pread64 syscall emulation. Signed-off-by: Andreas Schwab Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5f72209debc9..9f7eb7d7a896 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7009,8 +7009,8 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, _exit(arg1); return 0; /* avoid warning */ case TARGET_NR_read: - if (arg3 == 0) { - return 0; + if (arg2 == 0 && arg3 == 0) { + return get_errno(safe_read(arg1, 0, 0)); } else { if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0))) return -TARGET_EFAULT;