From patchwork Thu Jul 26 13:29:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 142971 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp467109ljj; Thu, 26 Jul 2018 06:33:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpegyBmS0hqIIjSHY4CmlWzLEzPgWZEvoGEIqluq+W4yUK7w5dhvRfV/IaMtd8aZRxELXpM4 X-Received: by 2002:ac8:3872:: with SMTP id r47-v6mr1792010qtb.69.1532612007657; Thu, 26 Jul 2018 06:33:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532612007; cv=none; d=google.com; s=arc-20160816; b=jqQa0tNFQ74CV1BuwttYcqg/Nfug7YA0X403QeuPCYGZaBWAw7uY8qtQMohxti54KO W9WUjN95zc5Bi7MD4FxGWoeX9D+AVOKiuqLNSCowYFV7HeLCQnBEiF9Gpp/tvDVsBHvI Cd9YGTxGBhJKmUbeeInTBiIVOylAUF6ou5+zduIhCaeIFiwLX4CBlaixJoL/XuZmddYq efCHH06Hw9TNbrVk2UjS2rsnu9sAeD2i4IkvvIny4pj6WXpPTRibWSL5V9vELGcZV5rk 9L4ZhZh3lLvhTxZpbU+mCHzmgYdIp7OiGVxA8xHd0d746tXGoK5tChvscOXWxGD844c5 fTlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=fPpsMUZsooFNseQTxSxS5/ciqBkWh8WBCac9H5dCwnE=; b=CSfn60pmW0X3QFm86Az+c4/fCTvUTxJj4RsbytIFAnpLXj9P2h6xvY79GNfptDFAJC to93fEnvVdivyhCW/qeK6Ji8f/ZbTiFzmhlBHYXv9lzFOL/CtorECEr1Sed+Hny9kGXO BPDOy58SdU8hAJveMiOLK4f36FlvOeik54LmPt5kj+pd0241h25/O75YEq1dLgzdeoOB AJWW7+liLoF1HxuWY2vyDeln+GrYHis9n75W2RH1/9KlahtFb6eEPzEvY3XUgOCcEWt5 M+kmgO/r7gHJN+mjWPamqdUD3dTmk7wj10XP3JqQhHH9t/bKDgnnBhNSNi/6xz7P7VNX bOQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F5uV0k5a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c62-v6si1397283qkh.295.2018.07.26.06.33.27 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 26 Jul 2018 06:33:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=F5uV0k5a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36036 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1figOV-0006Bw-4w for patch@linaro.org; Thu, 26 Jul 2018 09:33:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50798) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1figL4-0004PB-Qq 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-0004If-Qk for qemu-devel@nongnu.org; Thu, 26 Jul 2018 09:29:54 -0400 Received: from mail-wm0-x236.google.com ([2a00:1450:400c:c09::236]:40906) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1figL1-0004G4-K7 for qemu-devel@nongnu.org; Thu, 26 Jul 2018 09:29:51 -0400 Received: by mail-wm0-x236.google.com with SMTP id y9-v6so2037160wma.5 for ; Thu, 26 Jul 2018 06:29:51 -0700 (PDT) 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=fPpsMUZsooFNseQTxSxS5/ciqBkWh8WBCac9H5dCwnE=; b=F5uV0k5a0djBl5agBSRdD/wlyk3p4uZoTW4FnmVHaXr1S8ocNCsjCLnHy2/v4+jJci i4T7D1VFD+sVY2d2y4bYMFeRvszSNM5x8GEGKhvOcayOniwG2QWg+GLHm/cGAWr7Tv/K bpg4Y0h/f3be3ifTMrUIh6a1IeEqVfHzdxuT8= 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=fPpsMUZsooFNseQTxSxS5/ciqBkWh8WBCac9H5dCwnE=; b=lrh9+Y2I6knTDHU4d3KZXAYFCferXJ4hiuGe8hPvMEmRXNhUD9XLbvvz0jVv8oBWk+ 6nFzmHi1luBd9I1OQn6BWd8G7L+kS30nkZxqiF0Y6cA7EKsG6ZWmoyyu/JD3OKvz1Ob3 cWEm0G40k0vMx0yUWgDcDnA12zOe393mVMnF3L2tUBe7Ed+ovduG/ZmRSt3xj3NKT0c8 2bw6nuZnIiErWFwyfUOvhhFl3i8IQsPkvdR+oDDmI/o8VXq8HKb75Lu7+k3vmJQtlhGN FoFsWjFy70PCSPyVKXl/i2fOwo9vMnMwNmwMY5+TYTm06vuwdDjGG1m9Omr9WUWYtHCj 2esQ== X-Gm-Message-State: AOUpUlFEA+b27dAeKjtxvVKxPpyy3fVRPHk384XUR20yB5iSkgZSwBzb ptODN2sd1IzabDU9+XUb/esapQ== X-Received: by 2002:a1c:e189:: with SMTP id y131-v6mr1571278wmg.44.1532611790564; 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 i4-v6sm2208493wmf.4.2018.07.26.06.29.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Jul 2018 06:29:49 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id DB1233E0190; Thu, 26 Jul 2018 14:29:47 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Thu, 26 Jul 2018 14:29:47 +0100 Message-Id: <20180726132947.28538-3-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 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::236 Subject: [Qemu-devel] [PATCH v1 for 3.0 2/2] tests: add check_invalid_maps to test-mmap 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>, =?utf-8?q?Alex_Benn=C3=A9e?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This adds a test to make sure we fail properly for a 0 length mmap. There are most likely other failure conditions we should also check. Signed-off-by: Alex Bennée Cc: umarcor <1783362@bugs.launchpad.net> --- tests/tcg/multiarch/test-mmap.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) -- 2.17.1 Reviewed-by: Richard Henderson diff --git a/tests/tcg/multiarch/test-mmap.c b/tests/tcg/multiarch/test-mmap.c index 5c0afe6e49..7f62eba4e9 100644 --- a/tests/tcg/multiarch/test-mmap.c +++ b/tests/tcg/multiarch/test-mmap.c @@ -27,7 +27,7 @@ #include #include #include - +#include #include #define D(x) @@ -435,6 +435,19 @@ void checked_write(int fd, const void *buf, size_t count) fail_unless(rc == count); } +void check_invalid_mmaps(void) +{ + unsigned char *addr; + + /* Attempt to map a zero length page. */ + addr = mmap(NULL, 0, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + fprintf(stdout, "%s addr=%p", __func__, (void *)addr); + fail_unless(addr == MAP_FAILED); + fail_unless(errno == EINVAL); + + fprintf(stdout, " passed\n"); +} + int main(int argc, char **argv) { char tempname[] = "/tmp/.cmmapXXXXXX"; @@ -476,6 +489,7 @@ int main(int argc, char **argv) check_file_fixed_mmaps(); check_file_fixed_eof_mmaps(); check_file_unfixed_eof_mmaps(); + check_invalid_mmaps(); /* Fails at the moment. */ /* check_aligned_anonymous_fixed_mmaps_collide_with_host(); */