From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 0F08081377 for ; Fri, 6 Nov 2026 14:03:13 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A6E1r3k018733; Fri, 6 Nov 2026 17:01:54 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A6E1r3k018733 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="FHGYfl7v" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6A6E1iZH018707 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Fri, 6 Nov 2026 17:01:44 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6A6E1iZH018707 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-4925ef75fc4so738753f8f.1 for ; Fri, 06 Nov 2026 06:01:44 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErG9C/a592/dRuqd1qr/pwEEeYM1fzcGHbZYLXa7T610jeOWStrv36yx6CaDsX2kadx8iouaJg==@openvz.org X-Gm-Message-State: APuU4Z+oQx4Zx1iUSgHbKDEZ6vr4s4mEUk1Y/A3d86MHjx3986df9H2C xOkDd8NJo2f151N94NNUjjVImd9jDXFV6tjxcZUqxjozWFcByVcxZDwDADq583iYziyXvh+KZFW nMVB/jPRftnG6++2a4iH1KF3RKGz6uyUFqAGxZd067/EF+mOqqWb4aQ== X-Gm-Gg: AYBFou1UKJRKrZcasK9XHxi3VIYxYETq92O6e64yIF2XaLPWOBVNvPOubVOIoWypR9D D6oNpTFGpYcDbPstyWNhYrccQlgbkW8I2hJqMVhcVcRIhRhMOfn4iH4XNsEvTmpq+MyRGcm4gwU aOaLD3yd6CxEDAey/10tEGn0i9A5FaiaKV4B3B4HM0Iu1/ywr9OuXg3cQM3kFmLlNQbOyhvn5Ev tv2Hnt9YUpCXAagr6LQskhx9zFQbRPXaSJ4Q508Re17Ol9+VBmPfEb2LY7PoSz4D3GKrPpSylRW 01tCPDiNQTjUG7G0FRchPRck2NZ90oMGzyRSJoABFvpVt5HEbg5AUvOlrlmkwUIlnhCvY78D0jL pCFua8i0luy/If9bFTQ== X-Received: by 2002:adf:e199:0:b0:490:71a7:6f3c with SMTP id ffacd0b85a97d-49276d4da64mr4805427f8f.55.1793973704291; Fri, 06 Nov 2026 06:01:44 -0800 (PST) X-Received: by 2002:adf:e199:0:b0:490:71a7:6f3c with SMTP id ffacd0b85a97d-49276d4da64mr4805385f8f.55.1793973703798; Fri, 06 Nov 2026 06:01:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1793973703; cv=none; d=google.com; s=arc-20260327; b=qxISUGMv08mfYn4obTvOXYQVSvtjU5FC5PAlz1xaajljSTEr6iX7vtILaDidtEZBab GeVZpsFnW9r7hNGFlXK1zHhlyeQgZNv03pNBDI1ttjxYLA6dT3DNQiQQ8J62P6XUVDW5 HX2uqpsvdAB4MOE6qonth3qXNUZAqi+KUyiBiX+MZPZCkfnOoPSGzK80PhbOXOWXmv1S yR+N3yQp+KcOCE/DTbzsBFLutugtEtAMaGat+lOJv/Z6A0Qz5WUIBwR8Gx1cSX0VAQtR aL+hewqL/+XeW2vlMKBnx9KhFMpuVPj9LInTWXYp7uYEBdXGruapWRbVURAs6ityfHPK bQdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=s8NbpCzjD4RkVtTBzQW0n8G04m6BYb8DtJDYy5PH5ms=; fh=bRkZfFa6377EgOVW8zBDri2gGIQqe/ZeiH+ijEM/ROI=; b=bqjoZ+X0PGbEDwDNzeuNapjihrvdRNmItz0OrWYMhOshgZsc+LQzftt9vtNrW47cJG +1KQRFvW2S37lMYRwnDEnTE9/rxzlOoE43gEMzCkzVHmS7c/1rc3ebz16jdtlSbMUwFj VnTAmeqTPFVg3N0nGzlkr2zFd1WHlH+3dWMUYqvjgUwEM1MWt1wMS/Z16vfxN2Wwnbo7 ptoezGR6MiSZrgiHagugrRveOHD3yCKGvtWIleWm7xVJ+OIuAqjBHkc3XVZsTcfnaZFF 7PgFI6t4Bta/BOVFldEhoL1ntPY5GoqUQheKvUaam1BYiIfo/A+nm3AJIn7K5LkoVTLP pBlw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=FHGYfl7v; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-492d30e4e6csi3772538f8f.7.2026.11.06.06.01.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2026 06:01:43 -0800 (PST) Received-SPF: pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=FHGYfl7v; spf=pass (google.com: domain of khorenko@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=khorenko@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Message-Id:Content-Type:MIME-Version:Subject:Date :From; bh=s8NbpCzjD4RkVtTBzQW0n8G04m6BYb8DtJDYy5PH5ms=; b=FHGYfl7vvsQ97n9GoIW OWRfqtovJmNqBQ1qAInJPYxenPIQ+1aCr+xKMUKJltW2nK5NlNg9i9xPB9YOvBFI2P3WgvJaRlWHA YADaLACVX1piDyECTUBrRbEreEsm4beRkq2cYpNRZJ4v65v9ODYxh/T5k5UM+EiTZBj+qKdV1Cqe2 oduD82n+H4YqhsTu1x0NFeDCs4yN4y8KE8gz+CVDkM2GbApRYvsf89PGi0c9/V0jurJ02rJGAShXI /zODelXCJFk7DNB5fXtWaTerxM+AY4dO9o3ZAt7p1vT5rmdJpF+XkAqaYMoHv4s1YPILZuw9JIA+4 4wfXemlPuM0Sdkw==; Received: from ch-demo-asa.virtuozzo.com ([130.117.225.8] helo=f0.sw.ru) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xPKRj-00BceL-29; Fri, 06 Nov 2026 15:01:39 +0100 From: Konstantin Khorenko Date: Fri, 06 Nov 2026 15:01:35 +0100 MIME-Version: 1.0 Message-Id: <20261106-b4-prep-khorenko-vstor-153679-mbind-ve-v2-4-6327b23a2d93@virtuozzo.com> References: <20261106-b4-prep-khorenko-vstor-153679-mbind-ve-v2-0-6327b23a2d93@virtuozzo.com> In-Reply-To: <20261106-b4-prep-khorenko-vstor-153679-mbind-ve-v2-0-6327b23a2d93@virtuozzo.com> To: Pavel Tikhomirov , Vasileios Almpanis X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4962; i=khorenko@virtuozzo.com; h=from:subject:message-id; bh=J1fR3sbLqdm7IITW2nehszvgq+mHHASPTGV1ErInynk=; b=owEBbQKS/ZANAwAKAVGWCkf5YVwqAcsmYgBq7d3GZHu3XFZ9FBBYdyq6RKxqlzG9GQeJJG4Bf 489JR3f0h2JAjMEAAEKAB0WIQRWD23IPcXT0GO9CCxRlgpH+WFcKgUCau3dxgAKCRBRlgpH+WFc KpnnD/0XgJDDb3dGfUsYy70BHZxvDii+AkDO+RureEPXCN4//D7dyzxWUU4O44rfLp9qX3PJ8z6 7StOFlpOq1iZSevYO4CDm2mzlLNm1LXEX/s2H5HBPo8piCluFHiE4HIiMGT8r3dac5uZTwwgL1S BpJABhiDSURe3s+XxfuQLoGusGkfCRkox70nRzdVX+I//GqGJu7sPsD58kn8LTDGYtdAkndtWPG +Fu/RafUpwD8V0tYqFR4gj6BHeb+OQSpYF2hhf/BbkS8JgPTWu8a/BP6vErzsOXb/BJ8INOWl73 WlX0joQY7DaIb2B+A6IUDqsFsREAD4I9efDweSXJlorfLzY210LNwjUgAhYD9slqZeTHlRES0nI sFxXVITWNdelH3++gWr4qtUIYGes/s4NqeTci9RMOQfRte7TDY+JCUY0IPjSrvwn57nCHA1CPDc 8nFBObu2NkcM18kxjQA8mXG3dJ+KSwfR7jRSci44PZ3v9SA6szetzzug235+dair8wDVjiPIAbT vY4VJ/dd48S7rtUWrkkgK6B+66ghJwj7udEVSXOgkYNoBwzBIp4udjOo+bYta+O0nSwIdRYOfEX 6IlNK9tT6q7WLFiVZMWNoqNE1uY9VZ2J6YEXCZlPSDzRlS8pcj9z5+5B0EggEtmppRGqZ3yADP3 W8ssZjiAx8WSkmA== X-Developer-Key: i=khorenko@virtuozzo.com; a=openpgp; fpr=560F6DC83DC5D3D063BD082C51960A47F9615C2A X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 4/4] selftests/ve: check that tmpfs rejects mpol= in a VE X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org The test creates a tmpfs superblock with mpol=local and expects it to succeed on the host and to fail with -EINVAL in a VE. A tmpfs with size= is created in the VE as well, so the EINVAL can only come from the mpol= check, not from tmpfs being unavailable in the VE. https://virtuozzo.atlassian.net/browse/VSTOR-153679 Feature: mm: prohibit NUMA API inside CT Signed-off-by: Konstantin Khorenko --- tools/testing/selftests/ve/.gitignore | 1 + tools/testing/selftests/ve/Makefile | 1 + tools/testing/selftests/ve/ve_tmpfs_mpol_test.c | 123 ++++++++++++++++++++++++ 3 files changed, 125 insertions(+) diff --git a/tools/testing/selftests/ve/.gitignore b/tools/testing/selftests/ve/.gitignore index 5e07985c8fed3..2ff7669a393aa 100644 --- a/tools/testing/selftests/ve/.gitignore +++ b/tools/testing/selftests/ve/.gitignore @@ -5,3 +5,4 @@ ve_cpuid_override_test ve_vtty_stress ve_numa_migrate_test ve_numa_syscalls_prohibited_test +ve_tmpfs_mpol_test diff --git a/tools/testing/selftests/ve/Makefile b/tools/testing/selftests/ve/Makefile index 451a7e1cc17d1..cff4fc2a7639f 100644 --- a/tools/testing/selftests/ve/Makefile +++ b/tools/testing/selftests/ve/Makefile @@ -8,6 +8,7 @@ TEST_GEN_PROGS += ve_mount_accounting_test TEST_GEN_PROGS += ve_vtty_stress TEST_GEN_PROGS += ve_numa_migrate_test TEST_GEN_PROGS += ve_numa_syscalls_prohibited_test +TEST_GEN_PROGS += ve_tmpfs_mpol_test # CPUID faulting is x86-64 only. ARCH says "x86" for 32-bit too and lib.mk # picks the clang target by its emptiness, so decide by the compiler. diff --git a/tools/testing/selftests/ve/ve_tmpfs_mpol_test.c b/tools/testing/selftests/ve/ve_tmpfs_mpol_test.c new file mode 100644 index 0000000000000..6254f95fadece --- /dev/null +++ b/tools/testing/selftests/ve/ve_tmpfs_mpol_test.c @@ -0,0 +1,123 @@ +// SPDX-License-Identifier: GPL-2.0 +/* The tmpfs mpol= mount option works on the host and is rejected in a VE. */ +#define _GNU_SOURCE +#include +#include +#include +#include +#include +#include + +#include "../kselftest_harness.h" +#include "ve_selftest.h" + +/* Create a tmpfs superblock with one option set: 0 or the errno. */ +static int tmpfs_create(const char *key, const char *val) +{ + int fd, err = 0; + + fd = fsopen("tmpfs", FSOPEN_CLOEXEC); + if (fd < 0) + return errno; + if (fsconfig(fd, FSCONFIG_SET_STRING, key, val, 0) < 0 || + fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0) < 0) + err = errno; + close(fd); + return err; +} + +struct tmpfs_result { + int size_err; + int mpol_err; +}; + +static void run_tmpfs(struct tmpfs_result *res) +{ + res->size_err = tmpfs_create("size", "1M"); + res->mpol_err = tmpfs_create("mpol", "local"); +} + +FIXTURE(tmpfs_mpol) +{ + int cgv2_fd; + int ctid; +}; + +FIXTURE_SETUP(tmpfs_mpol) +{ + long ret; + + self->cgv2_fd = -1; + + if (geteuid() != 0) + SKIP(return, "creating a ve cgroup needs root"); + + ret = syscall(__NR_get_mempolicy, NULL, NULL, 0UL, 0UL, 0UL); + if (ret == -1 && errno == ENOSYS) + SKIP(return, "no NUMA API on the host"); + ASSERT_EQ(ret, 0); + + self->cgv2_fd = mount_cg2_fd(); + ASSERT_GE(self->cgv2_fd, 0); + ASSERT_EQ(write_file_at(self->cgv2_fd, "cgroup.subtree_control", + VE_CONTROLLERS), 0); + + self->ctid = make_ve(self->cgv2_fd, CTID_MIN); + ASSERT_GE(self->ctid, 0); +} + +FIXTURE_TEARDOWN(tmpfs_mpol) +{ + if (self->cgv2_fd >= 0) { + destroy_ve(self->cgv2_fd, self->ctid); + close(self->cgv2_fd); + } +} + +TEST_F(tmpfs_mpol, host_mpol_accepted) +{ + struct tmpfs_result res; + + run_tmpfs(&res); + EXPECT_EQ(res.size_err, 0) + TH_LOG("tmpfs size= on the host: %s", strerror(res.size_err)); + EXPECT_EQ(res.mpol_err, 0) + TH_LOG("tmpfs mpol= on the host: %s", strerror(res.mpol_err)); +} + +TEST_F(tmpfs_mpol, ve_mpol_rejected) +{ + struct tmpfs_result res; + int pipefd[2], status; + pid_t pid; + + ASSERT_EQ(pipe(pipefd), 0); + pid = fork(); + ASSERT_GE(pid, 0); + if (pid == 0) { + close(pipefd[0]); + if (enter_cgroup(self->cgv2_fd, self->ctid) < 0) + _exit(1); + if (unshare(CLONE_NEWVE) < 0) + _exit(2); + run_tmpfs(&res); + if (write(pipefd[1], &res, sizeof(res)) != sizeof(res)) + _exit(3); + _exit(0); + } + close(pipefd[1]); + ASSERT_EQ(waitpid(pid, &status, 0), pid); + ASSERT_TRUE(WIFEXITED(status)); + ASSERT_EQ(WEXITSTATUS(status), 0) + TH_LOG("VE child setup failed at step %d", WEXITSTATUS(status)); + ASSERT_EQ(read(pipefd[0], &res, sizeof(res)), sizeof(res)); + close(pipefd[0]); + + EXPECT_EQ(res.size_err, 0) + TH_LOG("tmpfs size= in a VE: %s", strerror(res.size_err)); + EXPECT_EQ(res.mpol_err, EINVAL) + TH_LOG("tmpfs mpol= in a VE: %s, expected EINVAL", + strerror(res.mpol_err)); +} + +TEST_HARNESS_MAIN -- 2.43.0 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel