From nobody Wed Nov 5 05:19:48 2025 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.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1532611886319796.8903758253601; Thu, 26 Jul 2018 06:31:26 -0700 (PDT) Received: from localhost ([::1]:36024 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1figMV-0005G6-Ky for importer@patchew.org; Thu, 26 Jul 2018 09:31:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1figL3-0004Oy-WB for qemu-devel@nongnu.org; Thu, 26 Jul 2018 09:29:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1figL1-0004G6-0r for qemu-devel@nongnu.org; Thu, 26 Jul 2018 09:29:54 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:39181) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1figL0-0004Dx-Pk for qemu-devel@nongnu.org; Thu, 26 Jul 2018 09:29:50 -0400 Received: by mail-wm0-x241.google.com with SMTP id h20-v6so2005017wmb.4 for ; Thu, 26 Jul 2018 06:29:50 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id d7-v6sm1547694wro.92.2018.07.26.06.29.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Jul 2018 06:29:48 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C88533E012E; Thu, 26 Jul 2018 14:29:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wgb29qVTxsksM7UXTcNm6n8cOSpKpK2tp1eBDFY0WJs=; b=J4qj3i2GGtcFgP3f6JnpPd1kG3YRz2J77491Q+GUXs8OZJKYEWtiHJbw9lEeYoh88+ oOsWfpIaicGqolG+UBhxVbXty6FnVD+7ER7UQEn3GpqhiXNeXPlOkKc/+j5LuEVAPGrt U4mJO3JCG/Cp+YUTUmzCOmIm4HqzfCEzONj1w= 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:mime-version:content-transfer-encoding; bh=wgb29qVTxsksM7UXTcNm6n8cOSpKpK2tp1eBDFY0WJs=; b=qb5rx1PfWM3T1iC+2LbxGW3Mci8sTSCL+uyduKMuFETO1qlZ5Qw8u4RTZn3ZWPFlU8 FTe9ai9QwL13c8X3ao5ntzdPlN6vNMIzsgpD5QmQ1TpFmspOol9HWCjxRzv4G4fjVNeS HvrWkRaNmgOrKxO6g8AhaIc4LXBkjbPnuyPsFVonMtzhWgNJVsGQk51fzOJGx5dvF3zG +QTic0qyKn8F//PmpxsPB7iN73rTn/xaoBqvTkejeCSJgY3PbdFaXngy793Yy1QcxhE/ gGKV78ZxOje1V0ccEZq0LqEBlS7nw+/dtQJvwtKwx0c0VB3k3AFKktm6VL4WO6nyWJeC kStg== X-Gm-Message-State: AOUpUlFV4ILCH2G52uFRC8eNwNjWNljjdAp5+dap19Qx6IDE6CbUffrq lYZYMrngGoy52Dxc1qWYhPt3kA== X-Google-Smtp-Source: AAOMgpcr51xM2OY3Y8j3RXIPQV20+yDKbskFPd5lTK7zYwu+ccJiHlv46l6YEfDtOBqrG36ZjSlVnA== X-Received: by 2002:a1c:9042:: with SMTP id s63-v6mr1520967wmd.91.1532611789732; Thu, 26 Jul 2018 06:29:49 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 26 Jul 2018 14:29:46 +0100 Message-Id: <20180726132947.28538-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180726132947.28538-1-alex.bennee@linaro.org> References: <20180726132947.28538-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH v1 for 3.0 1/2] linux-user/mmap.c: handle len = 0 maps correctly 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: umarcor <1783362@bugs.launchpad.net>, Riku Voipio , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 I've slightly re-organised the check to more closely match the sequence that the kernel uses in do_mmap(). Signed-off-by: Alex Benn=C3=A9e Cc: umarcor <1783362@bugs.launchpad.net> --- linux-user/mmap.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index d0c50e4888..3ef69fa2d0 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -391,14 +391,22 @@ abi_long target_mmap(abi_ulong start, abi_ulong len, = int prot, } #endif =20 - if (offset & ~TARGET_PAGE_MASK) { + if (!len) { errno =3D EINVAL; goto fail; } =20 len =3D TARGET_PAGE_ALIGN(len); - if (len =3D=3D 0) - goto the_end; + if (!len) { + errno =3D EINVAL; + goto fail; + } + + if (offset & ~TARGET_PAGE_MASK) { + errno =3D EINVAL; + goto fail; + } + real_start =3D start & qemu_host_page_mask; host_offset =3D offset & qemu_host_page_mask; =20 --=20 2.17.1