Received: by 10.223.164.221 with SMTP id h29csp160208wrb; Tue, 31 Oct 2017 11:42:34 -0700 (PDT) X-Google-Smtp-Source: ABhQp+RyVuX3sQ6eVM+LUJsTZ8htpS3kb3Udr8ufdcFepWq/P0a+iuz6ai25HMMBNsh5zNF4oLUB X-Received: by 10.99.95.86 with SMTP id t83mr2686017pgb.34.1509475354059; Tue, 31 Oct 2017 11:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509475354; cv=none; d=google.com; s=arc-20160816; b=CuvFY8rR0ighQUkOygmcccu3HQ5NL8mheSVaH0gE85QrXF2Dh4mAg/RkBKKG7kNYtJ TinlNJexlG+/rUN0ZxgLPwubl5jCc7ulbgqZ0Tm0S2BDSjxxJQaU9RgY5gmFRLy2qjNF B9QulyVAw+KTtpRb1ClHctVgYzAyj4fdVZi8LYAPxy1Z8O2LPQ+M6EGURz3l2DQspOjU Us1Uw77NnkluOsUg/2U9TRaV9E/NrMqRT6uwviX8AejCVTSzng+QircqTBHqxCK52mOm 4przW6cXpQo2tiK6qnWNn70VWyGR3bXpqUk33CnkNM6w9KA4Q6qnnUpxo/dxTzaF8uy8 R9Cw== 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 :dmarc-filter:arc-authentication-results; bh=ov1ExyZmXM6TNEGjsXR+1BIkbLt6maCxnAo1NcL/5uA=; b=Zxw1MjJuPbabxn+OxP1FOJvBjlpivAlECO7SCIGM539mCca/sLTNQ7QsQmdJN/iLIc kLx2q9l0CycrtzZNd/l7+eBeLU2BasVdiz3G8isOrXI6V2jeKzZbZYHplOMlNx37Z/MX knIbDZWbcrBhEiKBK11XHmhfmU2n7G2Hw8T2saImC0YIRxhopXNLjuPPJqwi0b+yveaa BEfep8hTeCaYnvWitsVGKM7hnpbe/sZM8xadMfPGf4m577JKFekYSUjqMJmdoQXdqCFr jkEgmwZ4TDUqTrpKAZi6GX+9lnnrr7d0zGaE/fsZdvfUTzdZx4IoIz/8voUQ/1Wz4nZx FcBA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 204si2113865pgc.742.2017.10.31.11.42.20; Tue, 31 Oct 2017 11:42:34 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932903AbdJaSlZ (ORCPT + 99 others); Tue, 31 Oct 2017 14:41:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35278 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932625AbdJaSlW (ORCPT ); Tue, 31 Oct 2017 14:41:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7150599D42; Tue, 31 Oct 2017 18:41:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7150599D42 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=marcandre.lureau@redhat.com Received: from localhost (ovpn-112-19.ams2.redhat.com [10.36.112.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13F105D962; Tue, 31 Oct 2017 18:41:18 +0000 (UTC) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: aarcange@redhat.com, hughd@google.com, nyc@holomorphy.com, mike.kravetz@oracle.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Subject: [PATCH 6/6] memfd-tests: test hugetlbfs sealing Date: Tue, 31 Oct 2017 19:40:52 +0100 Message-Id: <20171031184052.25253-7-marcandre.lureau@redhat.com> In-Reply-To: <20171031184052.25253-1-marcandre.lureau@redhat.com> References: <20171031184052.25253-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 31 Oct 2017 18:41:22 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Remove most of the special-casing of hugetlbfs now that sealing is supported. Signed-off-by: Marc-André Lureau --- tools/testing/selftests/memfd/memfd_test.c | 150 +++-------------------------- 1 file changed, 15 insertions(+), 135 deletions(-) diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index f94c6d1fb46f..f5028f800107 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -512,6 +512,10 @@ static void mfd_assert_grow_write(int fd) static char *buf; ssize_t l; + /* hugetlbfs does not support write */ + if (hugetlbfs_test) + return; + buf = malloc(mfd_def_size * 8); if (!buf) { printf("malloc(%d) failed: %m\n", mfd_def_size * 8); @@ -532,6 +536,10 @@ static void mfd_fail_grow_write(int fd) static char *buf; ssize_t l; + /* hugetlbfs does not support write */ + if (hugetlbfs_test) + return; + buf = malloc(mfd_def_size * 8); if (!buf) { printf("malloc(%d) failed: %m\n", mfd_def_size * 8); @@ -626,18 +634,13 @@ static void test_create(void) fd = mfd_assert_new("", 0, MFD_CLOEXEC); close(fd); - if (!hugetlbfs_test) { - /* verify MFD_ALLOW_SEALING is allowed */ - fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING); - close(fd); - - /* verify MFD_ALLOW_SEALING | MFD_CLOEXEC is allowed */ - fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING | MFD_CLOEXEC); - close(fd); - } else { - /* sealing is not supported on hugetlbfs */ - mfd_fail_new("", MFD_ALLOW_SEALING); - } + /* verify MFD_ALLOW_SEALING is allowed */ + fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING); + close(fd); + + /* verify MFD_ALLOW_SEALING | MFD_CLOEXEC is allowed */ + fd = mfd_assert_new("", 0, MFD_ALLOW_SEALING | MFD_CLOEXEC); + close(fd); } /* @@ -648,10 +651,6 @@ static void test_basic(void) { int fd; - /* hugetlbfs does not contain sealing support */ - if (hugetlbfs_test) - return; - printf("%s BASIC\n", MEMFD_STR); fd = mfd_assert_new("kern_memfd_basic", @@ -696,28 +695,6 @@ static void test_basic(void) close(fd); } -/* - * hugetlbfs doesn't support seals or write, so just verify grow and shrink - * on a hugetlbfs file created via memfd_create. - */ -static void test_hugetlbfs_grow_shrink(void) -{ - int fd; - - printf("%s HUGETLBFS-GROW-SHRINK\n", MEMFD_STR); - - fd = mfd_assert_new("kern_memfd_seal_write", - mfd_def_size, - MFD_CLOEXEC); - - mfd_assert_read(fd); - mfd_assert_write(fd); - mfd_assert_shrink(fd); - mfd_assert_grow(fd); - - close(fd); -} - /* * Test SEAL_WRITE * Test whether SEAL_WRITE actually prevents modifications. @@ -726,13 +703,6 @@ static void test_seal_write(void) { int fd; - /* - * hugetlbfs does not contain sealing or write support. Just test - * basic grow and shrink via test_hugetlbfs_grow_shrink. - */ - if (hugetlbfs_test) - return test_hugetlbfs_grow_shrink(); - printf("%s SEAL-WRITE\n", MEMFD_STR); fd = mfd_assert_new("kern_memfd_seal_write", @@ -759,10 +729,6 @@ static void test_seal_shrink(void) { int fd; - /* hugetlbfs does not contain sealing support */ - if (hugetlbfs_test) - return; - printf("%s SEAL-SHRINK\n", MEMFD_STR); fd = mfd_assert_new("kern_memfd_seal_shrink", @@ -789,10 +755,6 @@ static void test_seal_grow(void) { int fd; - /* hugetlbfs does not contain sealing support */ - if (hugetlbfs_test) - return; - printf("%s SEAL-GROW\n", MEMFD_STR); fd = mfd_assert_new("kern_memfd_seal_grow", @@ -819,10 +781,6 @@ static void test_seal_resize(void) { int fd; - /* hugetlbfs does not contain sealing support */ - if (hugetlbfs_test) - return; - printf("%s SEAL-RESIZE\n", MEMFD_STR); fd = mfd_assert_new("kern_memfd_seal_resize", @@ -841,32 +799,6 @@ static void test_seal_resize(void) close(fd); } -/* - * hugetlbfs does not support seals. Basic test to dup the memfd created - * fd and perform some basic operations on it. - */ -static void hugetlbfs_dup(char *b_suffix) -{ - int fd, fd2; - - printf("%s HUGETLBFS-DUP %s\n", MEMFD_STR, b_suffix); - - fd = mfd_assert_new("kern_memfd_share_dup", - mfd_def_size, - MFD_CLOEXEC); - - fd2 = mfd_assert_dup(fd); - - mfd_assert_read(fd); - mfd_assert_write(fd); - - mfd_assert_shrink(fd2); - mfd_assert_grow(fd2); - - close(fd2); - close(fd); -} - /* * Test sharing via dup() * Test that seals are shared between dupped FDs and they're all equal. @@ -875,15 +807,6 @@ static void test_share_dup(char *banner, char *b_suffix) { int fd, fd2; - /* - * hugetlbfs does not contain sealing support. Perform some - * basic testing on dup'ed fd instead via hugetlbfs_dup. - */ - if (hugetlbfs_test) { - hugetlbfs_dup(b_suffix); - return; - } - printf("%s %s %s\n", MEMFD_STR, banner, b_suffix); fd = mfd_assert_new("kern_memfd_share_dup", @@ -926,10 +849,6 @@ static void test_share_mmap(char *banner, char *b_suffix) int fd; void *p; - /* hugetlbfs does not contain sealing support */ - if (hugetlbfs_test) - return; - printf("%s %s %s\n", MEMFD_STR, banner, b_suffix); fd = mfd_assert_new("kern_memfd_share_mmap", @@ -954,32 +873,6 @@ static void test_share_mmap(char *banner, char *b_suffix) close(fd); } -/* - * Basic test to make sure we can open the hugetlbfs fd via /proc and - * perform some simple operations on it. - */ -static void hugetlbfs_proc_open(char *b_suffix) -{ - int fd, fd2; - - printf("%s HUGETLBFS-PROC-OPEN %s\n", MEMFD_STR, b_suffix); - - fd = mfd_assert_new("kern_memfd_share_open", - mfd_def_size, - MFD_CLOEXEC); - - fd2 = mfd_assert_open(fd, O_RDWR, 0); - - mfd_assert_read(fd); - mfd_assert_write(fd); - - mfd_assert_shrink(fd2); - mfd_assert_grow(fd2); - - close(fd2); - close(fd); -} - /* * Test sealing with open(/proc/self/fd/%d) * Via /proc we can get access to a separate file-context for the same memfd. @@ -990,15 +883,6 @@ static void test_share_open(char *banner, char *b_suffix) { int fd, fd2; - /* - * hugetlbfs does not contain sealing support. So test basic - * functionality of using /proc fd via hugetlbfs_proc_open - */ - if (hugetlbfs_test) { - hugetlbfs_proc_open(b_suffix); - return; - } - printf("%s %s %s\n", MEMFD_STR, banner, b_suffix); fd = mfd_assert_new("kern_memfd_share_open", @@ -1042,10 +926,6 @@ static void test_share_fork(char *banner, char *b_suffix) int fd; pid_t pid; - /* hugetlbfs does not contain sealing support */ - if (hugetlbfs_test) - return; - printf("%s %s %s\n", MEMFD_STR, banner, b_suffix); fd = mfd_assert_new("kern_memfd_share_fork", -- 2.15.0.rc0.40.gaefcc5f6f From 1583055063666993368@xxx Fri Nov 03 14:22:35 +0000 2017 X-GM-THRID: 1583055063666993368 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread