From nobody Fri Nov 13 00:47:15 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 4jQdrM6w1Rz6xw6r for ; Fri, 13 Nov 2026 00:47:15 +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 4jQdrM6HNpz4gLq for ; Fri, 13 Nov 2026 00:47:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794530835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JYLHYpSC3YJQLg5k2lT1lI2YKQTniyadsZGWuRWnOHc=; b=ngfwF2wm73EInb/FOeuhINhjGAj2sJwBEK9RezxMTtMfG1JJ03H2q7fJnFrnhrO8XYCig+ +tMWLFsjyV6GwrTdUJUJFJCn+nFV/0SxhMr3x3krvA/TXTeYlNEY3tuXt9ROeLmzOABRCV g1eVRXSS8XBzCJyAdqRn2SYSJPOx06WeKHjg4dCxYMbq+e2REC9gz+J3CdqVJsYvEL+zsm i8XUo1f9+dli/IFb0seaRxvjIVEgPY8GworbrTRbjELsoVLD1QY8SZoYPkWOocaO2quJW+ 1CBqyx3du8b0sjQ9p9l9RRQS8zwAaigW/hYLccPjIAG1MnjFRbQZpZVbepoOkg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794530835; b=kcjR9ahcPORRmBoArhApc09Neuk9ybWvX3bnhpO8DCU+aw1AnlNivgT2f/BK7QnhgR52DX cRa4WJffeEsx0axL+nMOiPXljUeW/t2t2O7dGVIqW/LjwUTdQ12O3x1L6gdBqARBkYyG3e 2w0cTolvA4VCbnKMhLzpvMDLz0QfZBhFhbOfT6QTBcFtk7m0qwWiMzJkdSo3gTs/iNUE3f EVeLHyu3b0eyr+deJ7iyL0eObDOocD7HVarZr5wJ5kiuDkcgLNPiqsrboGVw/VCHLePmov YnF4dGrG5689ugJCYNI+906yu05sfeGpYU/q0WRUZmFd73LmkxuA9l5I2ggcow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794530835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JYLHYpSC3YJQLg5k2lT1lI2YKQTniyadsZGWuRWnOHc=; b=N1kxyYL68kaJROxi9/fujdIyu8BDZwXL+Vrv/Hq1B1KAl566cjBt5N8XsSXNocYq8xtiSD pa4i6o73RuBsEbbNPciCszREwra5moh7fvVmB2avZUS4wmFexacjhB2ibqb0yPIXNZ+/5u ADiSWksS6kwHLeiDU78HhIk6FOOXE40mwI266xGoIa/Jd6s7tF+qnOutPoGKar7n3NVWTk hoNcEfxdrvFclQSIBzZA9i7GHAqFfDhXiD9iy4kB2bLHK3p3FHrgskz4RHSMgG4P/ssh0q Gr4vpElY/hZF3U9fEhuxC0HPRAe4wwpnZBhvN3ac0IWB/ZimXoBRqX/FbYTMlQ== 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 4jQdrM5yLnz1QB5 for ; Fri, 13 Nov 2026 00:47:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 16491 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 13 Nov 2026 00:47:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: ba02bbbe86ae - main - 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ba02bbbe86aeca0c95c8e7d12c1be357ebb3ddeb Auto-Submitted: auto-generated Date: Fri, 13 Nov 2026 00:47:15 +0000 Message-Id: <6af65e13.16491.58cbd288@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=ba02bbbe86aeca0c95c8e7d12c1be357ebb3ddeb commit ba02bbbe86aeca0c95c8e7d12c1be357ebb3ddeb Author: Dag-Erling Smørgrav AuthorDate: 2026-11-13 00:46:50 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-13 00:46:50 +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 --- tests/sys/kern/Makefile | 3 +++ tests/sys/kern/vn_io_fault1.c | 56 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) diff --git a/tests/sys/kern/Makefile b/tests/sys/kern/Makefile index a59168094c58..0a8615fad24e 100644 --- a/tests/sys/kern/Makefile +++ b/tests/sys/kern/Makefile @@ -82,6 +82,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+= logsigexit_test diff --git a/tests/sys/kern/vn_io_fault1.c b/tests/sys/kern/vn_io_fault1.c new file mode 100644 index 000000000000..d393d9d6b089 --- /dev/null +++ b/tests/sys/kern/vn_io_fault1.c @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 2026 Dag-Erling Smørgrav + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#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_BODY(big_unmapped_read, tc) +{ + char *buf; + size_t len = 3LU << 30; + ssize_t ret; + int fd; + + /* allocate a large buffer */ + if ((buf = malloc(len)) == NULL) + atf_tc_skip("failed to allocate buffer"); + + /* fault in just a tad more than the first 2 GB */ + for (size_t i = 0; i <= 2LU << 30; i += 4096) + buf[i] = 0; + + /* 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 the file into the buffer */ + 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)); + free(buf); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, big_unmapped_read); + return (atf_no_error()); +}