Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp625607imu; Fri, 9 Nov 2018 03:31:27 -0800 (PST) X-Google-Smtp-Source: AJdET5eEic9XmhmbtEQ8o5dbeXAxtDv4gYMUOZORgyBbiNKhUWm4NC0VQM8jMv6nba8yxFZmoPdl X-Received: by 2002:a17:902:4083:: with SMTP id c3-v6mr8603051pld.181.1541763087834; Fri, 09 Nov 2018 03:31:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541763087; cv=none; d=google.com; s=arc-20160816; b=Cs6I2bVSkBw1PNrmbBjrwCDD7WrcbWeLabzIwpRWUQOvcloKGWGY6vFWqG1+yQhrhX CPA8u6wn5GhroAnJk5ECsZM/aCZSTvAI44q9+gybYSQ/pKlqi7UTnieTcX66fSzBVKUe 3Wzs4tGTf3kpeBr2E0LJVPNisETIED6n6bxvjiXIYaqTN5wPOSVNwKq+bDK1TrTEpoGV IP/ZWBzBd1dU9VT3jRj35MyAn7eLeJ6AYB87MYeULZjnRKh/wGuI/dsh6iRVbWGRV0Kx DPt7Qts7XD8cCl/5YSMUFeuxGV58wmATRLpkLR9hSFK3YbOJUF5DM5ij1skS+aO6Z4eQ F2oQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PlS5AWWWpD/Zv7MPE6e/bI9tGD+2AhsGTOQaUcenEXU=; b=KBwAATqD10O3S5UvxIs4Xk7PS2A6A69LC6sVt4bbWJ3AydoQkWUFmcdV5dt/rVLKm5 0kQRXeVOX0gpL7cWdLn4YwCFqrWiYJezjuIRHqGbI0pydAjsswF+mZIQAMaXX8pIkG6u GQFJ3r94g/vq5afcJWl+kC0itzqPnZh6QyVtuisDocZGwA9kTcZefHQ63am67QHz/q7I mxl/w55hOD5oePwx7oLw16ApzZLqkV7AQ9qDEMVjny0vt6r1Iz1EXnDPlu7Sy1wEpSvE rLHpiTtbegFkB5VVRMu8FoLfijIhzi4dnIsx9rrKGekpnqMUvRVLTa8V26M0mrtjIMFj FZrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X0/w6Oti"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 199-v6si7759230pfu.273.2018.11.09.03.31.04; Fri, 09 Nov 2018 03:31:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="X0/w6Oti"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbeKIVKz (ORCPT + 99 others); Fri, 9 Nov 2018 16:10:55 -0500 Received: from mail-qk1-f195.google.com ([209.85.222.195]:37470 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727662AbeKIVKz (ORCPT ); Fri, 9 Nov 2018 16:10:55 -0500 Received: by mail-qk1-f195.google.com with SMTP id 131so917750qkd.4 for ; Fri, 09 Nov 2018 03:30:42 -0800 (PST) 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=PlS5AWWWpD/Zv7MPE6e/bI9tGD+2AhsGTOQaUcenEXU=; b=X0/w6OtiiQeqMm13Cd1JKzpHrzR4Ycp60TdmsTEkKOQ9HLRoEoRyxUXb1U3tS7UG81 1hTo32LSeZh4GUkyyPI+iG38zbr0rxWo/QLSnE3B/GeJtEGRT07qbY255XkSsQUPMmiQ P3lDxuVNiJnU7oDSwizINOykbv2gLVVhE/ym0= 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=PlS5AWWWpD/Zv7MPE6e/bI9tGD+2AhsGTOQaUcenEXU=; b=TP5dFifLV/aA2IEBUr7SZq4UMenrDgqxQDJgk0NXT+W56X4CHtAAMtQ0wP4f4nF8OO /6eZDvABuOAz8gDOELreSuLiI69fRHKOypGzHyoe3Tm0DymMjLT2mZF6DDhFUBqK5LlZ RuKM9OMTR+oT2njzNpvW7LPU9Wf3tTE1scNAJgwPa0wfctO+RroD3ld+G6Y2BQhafOoJ s/qA/Z2AVH2mJyAk4pHzcq22mD1yOajIBczBJ2ExbTCtKNQvSoNoULkx4RcZBrTfvv9W UfeJrxGoD4adbXEJ5z4lZzT7B5nLkqtJbfIt093GJth3p/dYY9hQyKdkrPjDGZqvV43O HZXg== X-Gm-Message-State: AGRZ1gI1J3laAS9kSh0L2xQtuLm0iwHVeQDznFdklhYqAaaVgoHyG+5L 8480c5g0wNcHjybdA+S98qu/RQ== X-Received: by 2002:aed:3b25:: with SMTP id p34mr8168968qte.310.1541763041572; Fri, 09 Nov 2018 03:30:41 -0800 (PST) Received: from workstation.celeiro.br ([168.194.163.12]) by smtp.gmail.com with ESMTPSA id p31sm5172435qkh.86.2018.11.09.03.30.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 03:30:40 -0800 (PST) From: Rafael David Tinoco To: gorcunov@gmail.com Cc: adobriyan@gmail.com, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, rafael.tinoco@linaro.org, shuah@kernel.org Subject: [PATCH] proc: fix and merge proc-self-map-file tests Date: Fri, 9 Nov 2018 09:30:36 -0200 Message-Id: <20181109113036.21512-1-rafael.tinoco@linaro.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108111105.GC13195@uranus.lan> References: <20181108111105.GC13195@uranus.lan> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Merge proc-self-map-files tests into one since this test should focus in testing readlink in /proc/self/map_files/* only, and not trying to test mapping virtual address 0. Lowest virtual address for user space mapping in other architectures, like arm, is *at least* *(PAGE_SIZE * 2) and NULL hint does not guarantee that when MAP_FIXED flag, important to this test, is given. This patch also fixes this issue in remaining test. Link: https://bugs.linaro.org/show_bug.cgi?id=3782 Signed-off-by: Rafael David Tinoco --- tools/testing/selftests/proc/.gitignore | 1 - tools/testing/selftests/proc/Makefile | 1 - .../selftests/proc/proc-self-map-files-001.c | 5 +- .../selftests/proc/proc-self-map-files-002.c | 85 ------------------- 4 files changed, 3 insertions(+), 89 deletions(-) delete mode 100644 tools/testing/selftests/proc/proc-self-map-files-002.c diff --git a/tools/testing/selftests/proc/.gitignore b/tools/testing/selftests/proc/.gitignore index 82121a81681f..d44ec8755879 100644 --- a/tools/testing/selftests/proc/.gitignore +++ b/tools/testing/selftests/proc/.gitignore @@ -3,7 +3,6 @@ /fd-003-kthread /proc-loadavg-001 /proc-self-map-files-001 -/proc-self-map-files-002 /proc-self-syscall /proc-self-wchan /proc-uptime-001 diff --git a/tools/testing/selftests/proc/Makefile b/tools/testing/selftests/proc/Makefile index 1c12c34cf85d..6c17557c2f9a 100644 --- a/tools/testing/selftests/proc/Makefile +++ b/tools/testing/selftests/proc/Makefile @@ -7,7 +7,6 @@ TEST_GEN_PROGS += fd-002-posix-eq TEST_GEN_PROGS += fd-003-kthread TEST_GEN_PROGS += proc-loadavg-001 TEST_GEN_PROGS += proc-self-map-files-001 -TEST_GEN_PROGS += proc-self-map-files-002 TEST_GEN_PROGS += proc-self-syscall TEST_GEN_PROGS += proc-self-wchan TEST_GEN_PROGS += proc-uptime-001 diff --git a/tools/testing/selftests/proc/proc-self-map-files-001.c b/tools/testing/selftests/proc/proc-self-map-files-001.c index 4209c64283d6..646d8d3fba3a 100644 --- a/tools/testing/selftests/proc/proc-self-map-files-001.c +++ b/tools/testing/selftests/proc/proc-self-map-files-001.c @@ -46,16 +46,17 @@ static void fail(const char *fmt, unsigned long a, unsigned long b) int main(void) { - const unsigned int PAGE_SIZE = sysconf(_SC_PAGESIZE); void *p; int fd; unsigned long a, b; + const long PAGE_SIZE = sysconf(_SC_PAGESIZE); fd = open("/dev/zero", O_RDONLY); if (fd == -1) return 1; - p = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_PRIVATE|MAP_FILE, fd, 0); + p = mmap((void *) (2 * PAGE_SIZE), PAGE_SIZE, PROT_NONE, + MAP_PRIVATE|MAP_FILE, fd, 0); if (p == MAP_FAILED) return 1; diff --git a/tools/testing/selftests/proc/proc-self-map-files-002.c b/tools/testing/selftests/proc/proc-self-map-files-002.c deleted file mode 100644 index 6f1f4a6e1ecb..000000000000 --- a/tools/testing/selftests/proc/proc-self-map-files-002.c +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright © 2018 Alexey Dobriyan - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -/* Test readlink /proc/self/map_files/... with address 0. */ -#include -#include -#include -#include -#include -#include -#include -#include - -static void pass(const char *fmt, unsigned long a, unsigned long b) -{ - char name[64]; - char buf[64]; - - snprintf(name, sizeof(name), fmt, a, b); - if (readlink(name, buf, sizeof(buf)) == -1) - exit(1); -} - -static void fail(const char *fmt, unsigned long a, unsigned long b) -{ - char name[64]; - char buf[64]; - - snprintf(name, sizeof(name), fmt, a, b); - if (readlink(name, buf, sizeof(buf)) == -1 && errno == ENOENT) - return; - exit(1); -} - -int main(void) -{ - const unsigned int PAGE_SIZE = sysconf(_SC_PAGESIZE); - void *p; - int fd; - unsigned long a, b; - - fd = open("/dev/zero", O_RDONLY); - if (fd == -1) - return 1; - - p = mmap(NULL, PAGE_SIZE, PROT_NONE, MAP_PRIVATE|MAP_FILE|MAP_FIXED, fd, 0); - if (p == MAP_FAILED) { - if (errno == EPERM) - return 2; - return 1; - } - - a = (unsigned long)p; - b = (unsigned long)p + PAGE_SIZE; - - pass("/proc/self/map_files/%lx-%lx", a, b); - fail("/proc/self/map_files/ %lx-%lx", a, b); - fail("/proc/self/map_files/%lx -%lx", a, b); - fail("/proc/self/map_files/%lx- %lx", a, b); - fail("/proc/self/map_files/%lx-%lx ", a, b); - fail("/proc/self/map_files/0%lx-%lx", a, b); - fail("/proc/self/map_files/%lx-0%lx", a, b); - if (sizeof(long) == 4) { - fail("/proc/self/map_files/100000000%lx-%lx", a, b); - fail("/proc/self/map_files/%lx-100000000%lx", a, b); - } else if (sizeof(long) == 8) { - fail("/proc/self/map_files/10000000000000000%lx-%lx", a, b); - fail("/proc/self/map_files/%lx-10000000000000000%lx", a, b); - } else - return 1; - - return 0; -} -- 2.19.1