From nobody Tue Nov 17 17:03:55 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jTWKR2sX0z71Qvl for ; Tue, 17 Nov 2026 17:03:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jTWKR1C82z4Dv0 for ; Tue, 17 Nov 2026 17:03:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5YVWIk5uYNJ4P3SuqhWecm5OJal+FDZCapt6Oe3+BLY=; b=h2FowT6qpkKBJWH57X5fXQi/QcVGbWKPNsK86PakzFOKklii6mClquGxdMfCakt5sNuuYK mPipl2P3NrT8MUtMH+GNbXmWxtqXymhwwHU2G92MnRRDSDVMemSQ2VT75psM83Q/72kw6j M/xDabiPFfF2EsKMsVvOd3fNKTctHuJFTYORtlq/uYaAQrcsmTkVVOykTKrRKZ8hv7jMnM iwoNpRTfrnOmhYF7wIVo+MmcP5bMZvCHnOYaf4OPbbIvXW2CffS0rdPsf0/6+/gttuQKRO sVTm65YoATnRykoCCr/1j0/K9ivb5hAlhZtRXkt+hGfC8GkdGZp+TTR3fyaKnA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794935035; b=oxub/FfcHdBhqXBC4CcttltuVKf6YTDUPhpVGXc89wfUnNouj3KYjsiPbqa2bZOsHnRnyd aGhEtGxK/rH4Za/I38DMBDQKL7ZJE90s8euYdpzMtJmYKpCc0n0FAeRtPRzS7MjK/9S2Ny YnrGB0jV+HO3VXQHkskgH42qpdUedeP8FwznZao3MID/Rys+bT5yfLm5BWqi+KuKmOpDOT UPO8/3vZR0pN3yyH7da9CzwYUzyEyP4DW+hJGngXwk9C3sXv9zByyX9TMa8tDYsDnPAMBi 4RuSSvTYvYpvEB29YSJue9kdE0SSzHDz3NsSSpQbevJnZgwxexIueDIluWoe+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794935035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=5YVWIk5uYNJ4P3SuqhWecm5OJal+FDZCapt6Oe3+BLY=; b=xrB7MlR4xvYvKPk5Q2WQSEDHXrxJryNQagV6YtKicgt+jLyQRc32GBiH4ZQkuLLIrVrGUl 25nbdDM7bXAjA5+Qj0FYI0C+jb0rSrpCj8Xn0uQwJJTDLiLkfw7JPvLPupH4nkA0nIBU3H sVGdv+7ClgcVty6czKjp/hbwOjjk5m500u3kKhTOOf9fm4pIajpioDJFqioU9FwkNSxiaY MPSJKgsW2Wsrj1/Fbu2C14LPcfPrjE9P6AQ5+vV7x9LFtuo98qIy9TKRkuoDN+YiyTyi16 xJ/CZhvkvKyiEVLEaeH48ZzvEdIf8ex+BJOmOWn5Hkct1UNX4LBySTXi35rFkw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jTWKR0rxXzrYf for ; Tue, 17 Nov 2026 17:03:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1e4a3 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 17:03:55 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Cc: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav From: Mark Johnston Subject: git: 8bd1c62819d3 - releng/14.4 - tests: Add test for vn_io_fault1 bug List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.4 X-Git-Reftype: branch X-Git-Commit: 8bd1c62819d393219e7f33f30c4eb0f73b4dbe1d Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 17:03:55 +0000 Message-Id: <6afc88fb.1e4a3.5937ab13@gitrepo.freebsd.org> The branch releng/14.4 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=8bd1c62819d393219e7f33f30c4eb0f73b4dbe1d commit 8bd1c62819d393219e7f33f30c4eb0f73b4dbe1d Author: Dag-Erling Smørgrav AuthorDate: 2026-11-13 00:46:50 +0000 Commit: Mark Johnston CommitDate: 2026-11-15 15:47:35 +0000 tests: Add test for vn_io_fault1 bug This bug was fixed in b487aca48535, but I did not have a regression test ready for it at the time. The test allocates a large buffer, faults part of it in and leaves the rest unmapped, then tries to read a 3 GiB file into it. If the bug is present, the read succeeds, but the return value exceeds the requested amount by exactly one page less than the amount that was prefaulted. PR: 298159 MFC after: 1 week Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D61475 (cherry picked from commit ba02bbbe86aeca0c95c8e7d12c1be357ebb3ddeb) tests: Improve vn_io_fault1 test * Declare that the test needs 4 GB of memory so it can be automatically skipped on systems with low memory. * Switch back to mmap() as in my initial prototype. Using malloc() is simpler, but on systems with malloc debugging enabled, malloc() will prefault the entire buffer, resulting in a false positive. Using mmap() also guarantees that the buffer is page-aligned, which renders the test determinstic: we now only need to prefault exactly 2 GB, and the difference between ret and len will be exactly the amount that we prefaulted. * To prefault the buffer, instead of a simple loop that writes zeroes to it, which a compiler might recognize as dead stores and eliminate, read the first INT_MAX bytes from the file into it. PR: 298159 Fixes: ba02bbbe86ae ("tests: Add test for vn_io_fault1 bug") Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D61508 (cherry picked from commit c5cff3df96c35aa3613c083f151e853b532d88cb) (cherry picked from commit 488e9144c154904391fb224dfce0095e9edff0e6) Approved by: so Security: FreeBSD-EN-26:30.vfs --- tests/sys/kern/Makefile | 3 ++ tests/sys/kern/vn_io_fault1.c | 66 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index 1c41c62b43a5..dac6cb7aa3ac 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -60,6 +60,9 @@ ATF_TESTS_C+= waitpid_nohang ATF_TESTS_C+= pdeathsig ATF_TESTS_C+= sigsys TEST_METADATA.sigsys+= is_exclusive="true" +.if ${MACHINE_ARCH:M*64*} +ATF_TESTS_C+= vn_io_fault1 +.endif ATF_TESTS_SH+= coredump_phnum_test ATF_TESTS_SH+= jailmeta diff --git a/tests/sys/kern/vn_io_fault1.c b/tests/sys/kern/vn_io_fault1.c new file mode 100644 index 000000000000..eabb35d2c9be --- /dev/null +++ b/tests/sys/kern/vn_io_fault1.c @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2026 Dag-Erling Smørgrav + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +#include +#include +#include +#include +#include +#include + +ATF_TC(big_unmapped_read); +ATF_TC_HEAD(big_unmapped_read, tc) +{ + atf_tc_set_md_var(tc, "descr", "Read a large amount of data " + "into a partially unmapped buffer"); + atf_tc_set_md_var(tc, "require.memory", "4G"); +} +ATF_TC_BODY(big_unmapped_read, tc) +{ + char *buf; + size_t len = 3LU << 30; + ssize_t ret; + int fd; + + /* allocate a large buffer */ + buf = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); + if (buf == MAP_FAILED) + atf_tc_skip("failed to allocate buffer"); + + /* create a large file */ + fd = open("big", O_RDWR | O_CREAT | O_TRUNC, 0600); + ATF_REQUIRE(fd >= 0); + ATF_REQUIRE_EQ_MSG(0, ftruncate(fd, len), + "failed to extend file: %m"); + + /* read part of the file into the buffer */ + ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET)); + ret = read(fd, buf, INT_MAX); + ATF_REQUIRE_MSG(ret >= 0, + "failed to read from file: %m"); + ATF_REQUIRE_EQ_MSG(INT_MAX, (size_t)ret, + "requested %zu bytes, got %zd", (size_t)INT_MAX, ret); + + /* read the entire file into the buffer */ + ATF_REQUIRE_EQ(0, lseek(fd, 0, SEEK_SET)); + ret = read(fd, buf, len); + ATF_REQUIRE_MSG(ret >= 0, + "failed to read from file: %m"); + ATF_REQUIRE_EQ_MSG(len, (size_t)ret, + "requested %zu bytes, got %zd", len, ret); + + /* done */ + ATF_CHECK_EQ(0, close(fd)); + ATF_CHECK_EQ(0, munmap(buf, len)); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, big_unmapped_read); + return (atf_no_error()); +}