From nobody Tue Nov 17 21:11:24 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 4jTcq126CVz71sdC for ; Tue, 17 Nov 2026 21:11:25 +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 4jTcq06NStz4G7y for ; Tue, 17 Nov 2026 21:11:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794949884; 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=2tVApca4KjqAS8zabsj0JwPgoQhJy1KgQOE9jE5Oj70=; b=aWpvv5DmvfEt2npodOZNmJNtwvTckIwUqBgHW6Mv/Lqbvr6/tHix6+OoEBGJMfMu3LjYbz jfStex5XtF3H+ZjUjS/wHjbfhgOGtXjv0VbDlj2z/I8Yyy/YUAp7ww4XEFduu9eGiXN5Gd OSXQ7K4czE9nkrYWlYB+UFaHQYzVbx2pZ82COVO/1IlPPIUh7ps6CfSkt+FD+y5QTL+5sj 3Ko7cU94kj7rzAUvr3hXo1c3T8Fao0l2B8aGQk7WXLBV1ZA/I7NFflaPBiWfG/H4E0IVCj NzlFDSXadP3RjjMYtXfYMJu6t+5OQ8/UR/1h7IkKMMArj2V7ZvDZ1v0xUmsefw== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794949884; b=JSOvnnqLdovt9y+bivqL4SpH7U8znLXRO8mA9xOcE21u0kdYZT/pZakLM2s0hBGD9lFw13 8Ix6pjOwPyzgkGRQF8Cnt7lZxHL8eXiQK9WjKIXoyFA1WBZtkg0opblKFicjXKxTj36ZNQ /d9IhHth70Mt8f9wdaPAf4/SCPoIxs193jYJqGAdKOuAP6CFfT6medneK/EuYNFTQ6hczp EpKJCnr5sKohd1x1LHkjdRFonfw/YxYPGIKKY2E+xHE2/nAH9vuhrHrdXvtX81ENXu6Z68 4tTIkOKzrDYws2WjWGLhXUwNt1iWqQHi+DfSIAc8+GtVLLKMUowEt1xH6sHc/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794949884; 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=2tVApca4KjqAS8zabsj0JwPgoQhJy1KgQOE9jE5Oj70=; b=GpdTzTXPHnsY6ZKelgLjc8g31NvsZ//1w8Wi6VtG4frM0VOfJ9ozyM3PM0sSCgyMOIGtdN H9mo9hUXOvzyQS7Ics0xMRIwdyexGBmebqvnIxpuGVboINqQRE7zU97WXTL6x8pMWM/jQA FxvmYoHz4+yK9i1lcRycjYMxPWOC2WZ1jYltkJuh8iIlizpk71gxM+1BrUhlh7iqJWQUj9 wAUMNmWcG8u0F5tf+8U9CGgOwNKtOJiMGL1XcVgit8haAta/LnY5Yv1hptiScDRDVcraP7 Y51ndaOOf1SYMrR0ugCcXrl/FkSC1cPbbTONROw+bSwx6W161lscFsoMEh01Mg== 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 4jTcq05kwLzyrR for ; Tue, 17 Nov 2026 21:11:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1a7c9 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Tue, 17 Nov 2026 21:11:24 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 4a7bf62ec173 - main - tmpfs: fix append-only file handling for writes and hole-punching 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: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4a7bf62ec173e87b07409b03c73fbc203e854358 Auto-Submitted: auto-generated Date: Tue, 17 Nov 2026 21:11:24 +0000 Message-Id: <6afcc2fc.1a7c9.4361dd29@gitrepo.freebsd.org> The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=4a7bf62ec173e87b07409b03c73fbc203e854358 commit 4a7bf62ec173e87b07409b03c73fbc203e854358 Author: Kyle Evans AuthorDate: 2026-11-17 21:10:38 +0000 Commit: Kyle Evans CommitDate: 2026-11-17 21:11:05 +0000 tmpfs: fix append-only file handling for writes and hole-punching Write protection assumed that O_APPEND handling at open time is sufficient, but the flag can be cleared with F_SETFL. That's maybe worth rejecting, but that's harder to do without some clear layering violations. Hole-punching also violates the spirit of append-only, so reject that on files that are append-only. Note that we don't reject IMMUTABLE here- UFS seems to historically not care if a file transitions to IMMUTABLE after it's opened, so follow suit here instead of trying to tighten it up. ZFS will apparently use the more constraining logic, but that's OK for now. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D61491 --- sys/fs/tmpfs/tmpfs_vnops.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index fe8507b4936a..895d1c7dc9f9 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -678,6 +678,15 @@ tmpfs_write(struct vop_write_args *v) return (0); if (ioflag & IO_APPEND) uio->uio_offset = node->tn_size; + + /* + * For better or worse, O_APPEND can be cleared after the file has been + * opened with F_SETFL. Only allow writes at the end for append-only + * files. + */ + if ((node->tn_flags & APPEND) != 0 && uio->uio_offset != node->tn_size) + return (EPERM); + error = vn_rlimit_fsizex(vp, uio, VFS_TO_TMPFS(vp->v_mount)-> tm_maxfilesize, &r, uio->uio_td); if (error != 0) { @@ -717,6 +726,13 @@ out: static int tmpfs_deallocate(struct vop_deallocate_args *v) { + struct tmpfs_node *node; + + /* Deallocation would zero existing data in the file. */ + node = VP_TO_TMPFS_NODE(v->a_vp); + if ((node->tn_flags & APPEND) != 0) + return (EPERM); + return (tmpfs_reg_punch_hole(v->a_vp, v->a_offset, v->a_len)); }