aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/fuse
Commit message (Collapse)AuthorAgeFilesLines
* fusefs(5): Fix a couple of typos in kernel messagesGordon Bergling5 days2-2/+2
| | | | | | | - s/intalled/installed/ - s/attributess/attributes/ MFC after: 1 week
* fusefs: fix page fault triggered by async notification when unmountedAlan Somers6 days1-0/+7
| | | | | | | | | | | | A FUSE daemon can send asynchronous notification to the kernel in order to, for example, invalidate an inode's cache. Fix a page fault that can happen if the file system isn't yet mounted, or is already unmounted, when that notification arrives. PR: 290519 MFC after: 1 week Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D53356
* knotes: kqueue: handle copy for trivial filtersKonstantin Belousov2025-10-181-0/+2
| | | | | | | | Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D52045
* fuse_flush: Reuse the struct mount *mp variableGleb Popov2025-10-141-2/+2
| | | | | Approved by: asomers Differential Revision: https://reviews.freebsd.org/D53082
* vfs: retire the NULLVP macroMateusz Guzik2025-09-271-2/+2
| | | | | | | | | | | | The kernel was already mostly using plain NULL, just whack it and be doen with the legacy. Churn generated with coccinelle: @@ @@ - NULLVP + NULL
* fusefs: fix a kernel panic regarding SCM_RIGHTSAlan Somers2025-09-191-3/+7
| | | | | | | | | | | | | | | | | | If the last copy of an open file resides within the socket buffer of a unix-domain socket, then VOP_CLOSE will be called with no thread information. Fix fusefs to handle that case, and add a regression test. Also add a test case for writes to a file that lies within a sockbuf. Along with close, a write from the writeback cache is the only other operation I can think of that might apply to a file residing in a sockbuf. PR: 289686 Reported by: iron.udjin@gmail.com MFC after: 1 week Sponsored by: ConnectWise Reviewed by: glebius, markj Differential Revision: https://reviews.freebsd.org/D52625
* fuse: Fix GID when sending FUSE_INTERRUPT to a FUSE daemonOlivier Certner2025-09-171-3/+1
| | | | | | | | | | | | | | | | | | Due to the partial-only changes of commit 46c07316f906 ("kern: adopt the cr_gid macro for cr_groups[0] more widely"), subsequent commit be1f7435ef218b1d ("kern: start tracking cr_gid outside of cr_groups[]") caused a mismatch between filling cr_groups[0] in 'reused_creds' in fuse_interrupt_send() and reading 'cr_gid' from it in fuse_setup_ihead(), with the consequence that the kernel would send a FUSE_INTERRUPT message to the FUSE deamon with an uninitialized GID in its header (which, besides being wrong, would disclose 4 bytes from its stack). Fixes: be1f7435ef218b1d ("kern: start tracking cr_gid outside of cr_groups[]") MFC after: 5 days MFC to: stable/15 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52255
* fusefs: spaces to tabs. No functional change.Alan Somers2025-09-151-1/+1
| | | | [skip ci]
* vfs: Introduce VN_ISDEV() macroDag-Erling Smørgrav2025-08-171-1/+1
| | | | | | | | | | | | | | We frequently need to check if a vnode refers to either a character or block special, so we might as well have a macro for it. We somewhat less frequently need to perform similar checks on things that aren't vnodes (usually a struct vattr *), so add VATTR_ISDEV() and a generic VTYPE_ISDEV() as well. Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D51947
* vfs: Add support for file cloning to VOP_COPY_FILE_RANGERick Macklem2025-08-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | NFSv4 has a separate CLONE operation from COPY with a couple of semantics differences. Unlike COPY, CLONE must complete the "copy on write" and cannot return partially copied. It also is required to use offsets (and the length if not to EOF) that are aligned to a buffer boundary. Since VOP_COPY_FILE_RANGE() can already do "copy on write" for file systems that support it, such as ZFS with block cloning enabled, all this patch does is add a flag called COPY_FILE_RANGE_CLONE so that it will conform to the rule that it must do a "copy on write" to completion. The patch also adds a new pathconf(2) name _PC_CLONE_BLKSIZE, which acquires the blocksize requirement for cloning and returns 0 for file systems that do not support the "copy on write" feature. (This is needed for the NFSv4.2 clone_blksize attribute.) This patch will allow the implementation of CLONE for NFSv4.2. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D51808
* fusefs: don't fake the mountpoint's stat info before FUSE_INIT completesAlan Somers2025-08-051-25/+9
| | | | | | | | | | | | | | | Ever since the first GSoC contribution, fusefs has had a curious behavior. If the daemon hasn't finished responding to FUSE_INIT, fuse_vnop_getattr would reply to VOP_GETATTR requests for the mountpoint by returning all zeros. I don't know why. It isn't necessary for unmounting, even if the daemon is dead. Delete that behavior. Now VOP_GETATTR for the mountpoint will wait for the daemon to be ready, just like it will for any other vnode. Reported by: Vassili Tchersky Sponsored by: ConnectWise Differential Revision: https://reviews.freebsd.org/D50800
* kern: adopt the cr_gid macro for cr_groups[0] more widelyKyle Evans2025-07-243-5/+5
| | | | | | | | | | | | | | | | A future change may split cr_gid out of cr_groups[0] so that there's a cleaner separation between the supplemental groups and the effective group. Do the mechanical conversion where we can, and drop some comments where we need further work because some assumptions about cr_gid == cr_groups[0] have been made. This should not be a functional change, but downstreams and other out-of-tree code are advised to investigate their usage of cr_groups sooner rather than later, as a future change will render assumptions about these two being equivalent harmful. Reviewed by: asomers, kib, olce Differential Revision: https://reviews.freebsd.org/D51153
* fusefs: exterrorize fuse_vnops.cGleb Popov2025-07-041-74/+123
| | | | | Approved by: asomers Pull Request: https://github.com/freebsd/freebsd-src/pull/1727
* fuse_vnop_allocate: Drop duplicated vfs_isrdonly() checkGleb Popov2025-07-041-2/+0
| | | | | Approved by: asomers Pull Request: https://github.com/freebsd/freebsd-src/pull/1727
* fusefs: Upgrade FUSE protocol to version 7.35.Claudiu I. Palincas2025-07-033-3/+21
| | | | | | | | | | | | Upgrade the FUSE API from protocol 7.33 to 7.35. Add support for FOPEN_NOFLUSH, introduced in 7.35. Also, reduce diffs vis-a-vis upstream by factoring out an ioctl type, a change missed in d5e3cf41e89. Signed-off-by: Claudiu I. Palincas <mscotty@protonmail.ch> Reviewed by: asomers Pull Request: https://github.com/freebsd/freebsd-src/pull/1744
* fusefs: Fix returned error code in fuse_device_write()Gleb Popov2025-06-211-1/+1
| | | | | | | Reported by: asomers Fixes: f9c9122d5ab9b106ddc6897454350b31de838631 Differential Revision: https://reviews.freebsd.org/D50831
* Internal scheduling priorities: Always use symbolic onesOlivier Certner2025-06-183-4/+4
| | | | | | | | | | | | | | | | | | | | | | Replace priorities specified by a base priority and some hardcoded offset value by symbolic constants. Hardcoded offsets prevent changing the difference between priorities without changing their relative ordering, and is generally a dangerous practice since the resulting priority may inadvertently belong to a different selection policy's range. Since RQ_PPQ is 4, differences of less than 4 are insignificant, so just remove them. These small differences have not been changed for years, so it is likely they have no real meaning (besides having no practical effect). One can still consult the changes history to recover them if ever needed. No functional change (intended). MFC after: 1 month Event: Kitchener-Waterloo Hackathon 202506 Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45390
* fusefs: First take on exterrorizingGleb Popov2025-06-172-25/+42
| | | | | | Reviewed by: kib, asomers Approved by: kib, asomers Differential Revision: https://reviews.freebsd.org/D50831
* fusefs: fix a panic in vop_close with a CTL consumerAlan Somers2025-06-151-0/+3
| | | | | | | | | | | Kernel consumers like CTL may lack ucred objects. That led to a panic when CTL closed a fuse file, if atime was enabled on the mountpoint. Fix it by checking the ucred during close. PR: 283402 MFC after: 2 weeks Sponsored by: ConnectWise Differential Revision: https://reviews.freebsd.org/D48165
* fusefs: add more checks for buggy FUSE serversAlan Somers2025-06-133-0/+34
| | | | | | | | | | | | | | | | | * If a FUSE file system is NFS-exported (either by a kernel or userspace NFS server), then it must support FUSE_LOOKUP operations for ".". But if the response reports a different nodeid than the request, that's very bad. Fail the operation and warn the operator. * In general, a FUSE file may have a distinct "nodeid" and "inode number". But it the file system is NFS-exported (either by a kernel or userspace NFS server), then those two must match, because the NFS server will do VFS_VGET operations using the inode number. If they don't match, warn the operator. MFC after: 2 weeks Sponsored by: ConnectWise Differential Revision: https://reviews.freebsd.org/D48471
* fusefs: Fix a panic when unmounting before initAlan Somers2025-06-121-0/+3
| | | | | | | | | | | | | | fusefs would page fault due to the following sequence of events: * The server did not respond to FUSE_INIT in timely fashion. * Some other process tried to do unmount. * That other process got killed by a signal. * The server finally responded to FUSE_INIT. PR: 287438 MFC after: 2 weeks Sponsored by: ConnectWise Reviewed by: arrowd Differential Revision: https://reviews.freebsd.org/D50799
* fusefs: delete dead codeAlan Somers2025-06-052-8/+1
| | | | | | | | | | These lines have been commented out ever since the first import of fuse. The intention seems to be for the original developer to experiment with different error handling strategies, but they're very obsolete by now. Delete them. MFC after: 2 weeks Sponsored by: ConnectWise
* namei: Fix cn_flags width in various placesMark Johnston2025-05-271-5/+4
| | | | | | | | | This truncation is mostly harmless today, but fix it anyway to avoid pain later down the road. Reviewed by: olce, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D50417
* fusefs: Upgrade FUSE protocol to version 7.33.Claudiu I. Palincas2025-04-292-10/+53
| | | | | | | | | | | This commit upgrades the FUSE API to protocol 7.33, it doesn't implement any of protocol 7.33's new features, setxattr is tested for binary compatibility with protocol version 7.32. Update sys/fs/fuse/fuse_vnops.c Reviewed by: Alan Somers <asomers@FreeBSD.org> Pull Request: https://github.com/freebsd/freebsd-src/pull/1681
* fusefs: fix a memory leakAlan Somers2024-12-231-1/+1
| | | | | | | | | Fix a leak of a fuse_ticket structure. The leak mostly affected NFS-exported fuse file systems, and was triggered by a failure during FUSE_LOOKUP. MFC after: 2 weeks Sponsored by: ConnectWise
* fusefs: ignore FUSE_NO_OPEN(DIR)_SUPPORT flagsCismonX2024-12-204-21/+11
| | | | | | | | | | | | | The FUSE_NO_OPEN_SUPPORT and FUSE_NO_OPENDIR_SUPPORT flags are only meant to indicate kernel features, and should be ignored if they appear in the FUSE_INIT reply flags. Also fix the corresponding test cases. MFC after: 2 weeks Reviewed by: Alan Somers <asomers@FreeBSD.org> Signed-off-by: CismonX <admin@cismon.net> Pull Request: https://github.com/freebsd/freebsd-src/pull/1509
* fusefs: FUSE_NOTIFY_INVAL_* must busy the mountpointAlan Somers2024-12-131-1/+8
| | | | | | | | | | | | Unusually, the FUSE_NOTIFY_INVAL_INODE and FUSE_NOTIFY_INVAL_ENTRY messages are fully asynchronous. The server sends them to the kernel unsolicited. That means that unlike every other fuse message coming from the server, these two arrive to a potentially unbusied mountpoint. So they must explicitly busy it. Otherwise a page fault could result if the mountpoint were being unmounted. Reported by: JSML4ThWwBID69YC@protonmail.com MFC after: 2 weeks
* fusefs: Upgrade FUSE protocol to version 7.32.Claudiu I. Palincas2024-12-121-3/+78
| | | | | | | | This commit upgrades the FUSE API to protocol 7.32. It doesn't implement any of protocol 7.32's new features. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D48040
* kern: Make fileops and filterops tables const where possibleMark Johnston2024-11-261-2/+2
| | | | | | No functional change intended. MFC after: 1 week
* fusefs: fix an uninitialized memory access in fuse_vnop_deallocateAlan Somers2024-09-081-1/+1
| | | | | | | | | | | | | If the FUSE_GETATTR issued to query a file's size during fuse_vnop_deallocate failed for any reason, then fuse_vnop_deallocate would attempt to destroy an uninitialized fuse_dispatcher struct, with a crash the likely result. This bug only affects FUSE file systems that implement FUSE_FALLOCATE, and is unlikely to be seen on those that don't disable attribute caching. Reported by: Coverity Scan CID: 1505308 MFC after: 2 weeks
* fusefs: Fix warning formattingMark Johnston2024-08-271-2/+2
| | | | | | Reviewed by: asomers MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46456
* fusefs: fix two bugs regarding _PC_MIN_HOLE_SIZEAlan Somers2024-06-241-10/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Background: If a user does pathconf(_, _PC_MIN_HOLE_SIZE) on a fusefs file system, the kernel must actually issue a FUSE_LSEEK operation in order to determine whether the server supports it. We cache that result, so we only have to send FUSE_LSEEK the first time that _PC_MIN_HOLE_SIZE is requested on any given mountpoint. Problem 1: Unlike fpathconf, pathconf operates on files that may not be open. But FUSE_LSEEK requires the file to be open. As described in PR 278135, FUSE_LSEEK cannot be sent for unopened files, causing _PC_MIN_HOLE_size to wrongly report EINVAL. We never noticed that before because the fusefs test suite only uses fpathconf, not pathconf. Fix this bug by opening the file if necessary. Problem 2: On a completely sparse file, with no data blocks at all, FUSE_LSEEK with SEEK_DATA would fail to ENXIO. That's correct behavior, but fuse_vnop_pathconf wrongly interpreted that as "FUSE_LSEEK not supported". Fix the interpretation. PR: 278135 MFC after: 1 week Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D44618
* Stop treating size 0 as unknown size in vnode_create_vobject().Pawel Jakub Dawidek2024-05-232-2/+2
| | | | | | | | | | | | | | | | | | | | | Whenever file is created, the vnode_create_vobject() function will try to determine its size by calling vn_getsize_locked() as size 0 is ambigious: it means either the file size is 0 or the file size is unknown. Introduce special value for the size argument: VNODE_NO_SIZE. Only when it is given, the vnode_create_vobject() will try to obtain file's size on its own. Introduce dedicated vnode_disk_create_vobject() for use by g_vfs_open(), so we don't have to call vn_isdisk() in the common case (for regular files). Handle the case of mediasize==0 in g_vfs_open(). Reviewed by: alc, kib, markj, olce Approved by: oshogbo (mentor), allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D45244
* Fix build.Pawel Jakub Dawidek2024-05-221-0/+2
|
* Simplify the code.Pawel Jakub Dawidek2024-05-221-13/+5
| | | | | | | Obtained from: Fudo Security Reviewed by: asomers, imp Approved by: oshogbo (mentor) Differential Revision: https://reviews.freebsd.org/D45247
* fusefs: correct a commentAlan Somers2024-04-041-4/+5
| | | | | | | [skip ci] MFC after: 1 week Sponsored by: Axcient
* fusefs: only test for incoherency if FN_SIZECHANGE is setEmil Tsalapatis2024-02-091-2/+2
| | | | | | | | | | | | | | FUSE emits spurious incoherency warnings in writethrough mode. The warnings are triggered by setattr calls generated by vnode truncation turning the cached va_size vattr stale, causing comparisons with the fresh version provided by the server to fail. Only validate the vnode's va_size vattr if the FN_SIZECHANGE flag is set. This is a part of the research work at RCSLab, University of Waterloo. Reviewed by: asomers MFC after: 1 week Pull Request: https://github.com/freebsd/freebsd-src/pull/1110
* fusefs: fix invalid value for st_birthtime.tv_nsecAlan Somers2024-02-042-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | If a file system's on-disk format does not support st_birthtime, it isn't clear what value it should return in stat(2). Neither our man page nor the OpenGroup specifies. But our convention for UFS and msdosfs is to return { .tv_sec = -1, .tv_nsec = 0 }. fusefs is different. It returns { .tv_sec = -1, .tv_nsec = -1 }. It's done that ever since the initial import in SVN r241519. Most software apparently handles this just fine. It must, because we've had no complaints. But the Rust standard library will panic when reading such a timestamp during std::fs::metadata, even if the caller doesn't care about that particular value. That's a separate bug, and should be fixed. Change our invalid value to match msdosfs and ufs, pacifying the Rust standard library. PR: 276602 MFC after: 1 week Sponsored by: Axcient Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D43590
* fusefs(5): Fix a typo in a SDT probeGordon Bergling2024-01-201-1/+1
| | | | | | - s/userpace/userspace/ MFC after: 5 days
* fusefs: fix an interaction between copy_file_range and mmapAlan Somers2024-01-151-0/+1
| | | | | | | | | If a copy_file_range operation tries to read from a page that was previously written via mmap, that page must be flushed first. MFC after: 2 weeks Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43451
* Add vnode_pager_clean_{a,}sync(9)Konstantin Belousov2024-01-111-5/+2
| | | | | | | | | Bump __FreeBSD_version for ZFS use. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D43356
* fuse: Fix typo (triple S)Jose Luis Duran2023-12-281-1/+1
| | | | | Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/955
* vn_copy_file_range(): provide ENOSYS fallback to vn_generic_copy_file_range()Konstantin Belousov2023-11-281-5/+2
| | | | | | | Reviewed by: markj, Olivier Certner <olce.freebsd@certner.fr> Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42603
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-279-9/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* fuse_vnop_copy_file_range(): add safetyKonstantin Belousov2023-11-161-1/+2
| | | | | | | | | | v_mount for unlocked vnode could be NULL, check for it. Explain why it is safe to access fs-specific data for mp if it is read as non-NULL. Reviewed by: asomers, jah Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42625
* fuse_vnop_copy_file_range(): use vn_lock_pair()Konstantin Belousov2023-11-161-17/+5
| | | | | | | Reviewed by: asomers, jah Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42625
* fusefs: sanitize FUSE_READLINK results for embedded NULsAlan Somers2023-10-072-0/+8
| | | | | | | | | | | | If VOP_READLINK returns a path that contains a NUL, it will trigger an assertion in vfs_lookup. Sanitize such paths in fusefs, rejecting any and warning the user about the misbehaving server. PR: 274268 MFC after: 1 week Sponsored by: Axcient Reviewed by: mjg, markj Differential Revision: https://reviews.freebsd.org/D42081
* fusefs: fix some bugs updating atime during closeAlan Somers2023-09-211-4/+23
| | | | | | | | | | | | | | | | | When using cached attributes, we must update a file's atime during close, if it has been read since the last attribute refresh. But, * Don't update atime if we lack write permissions to the file or if the file system is readonly. * If the daemon fails our atime update request for any reason, don't report this as a failure for VOP_CLOSE. PR: 270749 Reported by: Jamie Landeg-Jones <jamie@catflap.org> MFC after: 1 week Sponsored by: Axcient Reviewed by: pfg Differential Revision: https://reviews.freebsd.org/D41925
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-169-18/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-167-14/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/