aboutsummaryrefslogtreecommitdiff
path: root/sys/fs/cuse
Commit message (Collapse)AuthorAgeFilesLines
* cuse: Fix cdevpriv bugs in cuse_client_open()Christos Margiolis2025-11-131-13/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | If devfs_set_cdevpriv() fails, we will panic when we enter the cuse_client_free() callback, for a number of reasons: - pcc->server is not yet assigned, so we'll use a NULL pointer. - pcc has not yet been added to the pcs->hcli TAILQ, but we'll try to remove it. - pccmd->sx and pccmd->cv are not yet initializated, but we'll try to destroy them. Even if we'd get past all these somehow, we'd still get two errors in the devfs_set_cdevpriv() failure block: - We'll unref the server twice, once in cuse_client_free(), and again in cuse_client_open(). - A double-free panic, since we'd be trying to free(pcc), which has already been freed in cuse_client_free(). Fix all those issues. While here, also get rid of some unnecessary devfs_clear_cdevpriv(). Sponsored by: The FreeBSD Foundation MFC after: 1 week Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D53708
* 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
* cuse: Use NULL for SYSUNINIT's last arg, which is a pointer typeZhenlei Huang2024-12-091-1/+1
| | | | MFC after: 3 days
* kern: Make fileops and filterops tables const where possibleMark Johnston2024-11-261-2/+2
| | | | | | No functional change intended. MFC after: 1 week
* sys: Remove $FreeBSD$: one-line .c comment patternWarner Losh2023-08-163-3/+0
| | | | Remove /^/[*/]\s*\$FreeBSD\$.*\n/
* cuse(3): Cosmetic change about testing boolean values.Hans Petter Selasky2022-10-041-2/+2
| | | | | | | | | No functional change intended. Differential Revision: https://reviews.freebsd.org/D36633 Suggested by: jrtc27@ and avg@ MFC after: 1 week Sponsored by: NVIDIA Networking
* cuse(3): Optimise small reads and writes.Hans Petter Selasky2022-10-031-6/+130
| | | | | | | | | | When doing small reads and writes use an intermediate buffer to store the data to save locking the remote process to access data. Reviewed by: imp @ Differential Revision: https://reviews.freebsd.org/D36633 MFC after: 1 week Sponsored by: NVIDIA Networking
* cuse(3): Use bool type for boolean value instead of int type.Hans Petter Selasky2022-10-031-4/+4
| | | | | | | | | No functional change intended. Reviewed by: imp @ Differential Revision: https://reviews.freebsd.org/D36633 MFC after: 1 week Sponsored by: NVIDIA Networking
* cuse(3): Allow shared memory allocations up to, but excluding 2 GBytes.Hans Petter Selasky2022-07-203-73/+46
| | | | | | | | | | | | Currently the cuse(3) mmap(2) offset is split into 128 banks of 16 Mbytes. Allow cuse(3) to make allocations that span multiple banks at the expense of any fragmentation issues that may arise. Typically mmap(2) buffers are well below 16 Mbytes. This allows 8K video resolution to work using webcamd. Reviewed by: markj @ Differential Revision: https://reviews.freebsd.org/D35830 MFC after: 1 week Sponsored by: NVIDIA Networking
* cuse(3): Fix an off-by-one.Hans Petter Selasky2022-07-201-1/+1
| | | | | | | The page allocation limit is inclusive and not exclusive. MFC after: 1 week Sponsored by: NVIDIA Networking
* cuse(3): Remove PAGE_SIZE from libcuse.Hans Petter Selasky2022-06-252-4/+11
| | | | | | | | To allow for a dynamic page size on arm64 remove the static value from libcuse. Differential Revision: https://reviews.freebsd.org/D35585 MFC after: 1 week Sponsored by: NVIDIA Networking
* Fix for loading cuse.ko via rc.d . Make sure we declare the cuse(3)Hans Petter Selasky2020-10-231-0/+18
| | | | | | | | | | | | module by name and not only by the version information, so that "kldstat -q -m cuse" works. Found by: Goran Mekic <meka@tilda.center> MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=366961
* fs: clean up empty lines in .c and .h filesMateusz Guzik2020-09-011-8/+0
| | | | Notes: svn path=/head/; revision=365070
* cuse: Stop checking for failures from malloc(M_WAITOK).Mark Johnston2020-07-231-13/+0
| | | | | | | | | | | PR: 240545 Submitted by: Andrew Reiter <arr@watson.org> Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25765 Notes: svn path=/head/; revision=363446
* Fine grain locking inside the cuse(3) kernel module.Hans Petter Selasky2020-03-301-141/+171
| | | | | | | | | | | | | | Implement one mutex per cuse(3) server instance which also cover the clients belonging to the given server instance. This should significantly reduce the mutex congestion inside the cuse(3) kernel module when multiple servers are in use. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=359452
* Free all allocated unit IDs in cuse(3) after the client characterHans Petter Selasky2019-06-251-2/+2
| | | | | | | | | | | devices have been destroyed to avoid creating character devices with identical name. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=349368
* Fix for deadlock situation in cuse(3)Hans Petter Selasky2019-06-251-14/+29
| | | | | | | | | | | | The final server unref should be done by the server thread to prevent deadlock in the client cdevpriv destructor, which cannot destroy itself. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=349367
* Implement flag for telling cuse(3) clients if the peer is running in 32-bitHans Petter Selasky2019-04-182-2/+7
| | | | | | | | | | | compat mode or not. This is useful when implementing compatibility ioctl(2) handlers in userspace. MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=346356
* Use NULL for SYSINIT's last arg, which is a pointer typeEd Maste2018-05-181-1/+1
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=333806
* Move most of the contents of opt_compat.h to opt_global.h.Brooks Davis2018-04-061-2/+0
| | | | | | | | | | | | | | | | | | | | | opt_compat.h is mentioned in nearly 180 files. In-progress network driver compabibility improvements may add over 100 more so this is closer to "just about everywhere" than "only some files" per the guidance in sys/conf/options. Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of sys/compat/linux/*.c. A fake _COMPAT_LINUX option ensure opt_compat.h is created on all architectures. Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the set of compiled files. Reviewed by: kib, cem, jhb, jtl Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14941 Notes: svn path=/head/; revision=332122
* Allow CUSE(3) to free all memory mapped memory by using regular SWAP objectsHans Petter Selasky2017-11-032-130/+137
| | | | | | | | | | | | | | | | | | | instead of malloc(). The SWAP objects are automagically freed when there are no more consumers. This greatly simplifies the mmap logic inside CUSE(3) in the kernel. This change fixes an issue where mmapped memory can accumulate and never get freed, if many different mmap sizes are needed over time. Further this change fixes memory leaks when the CUSE(3) kernel module is unloaded. While at it make sure the CUSE_ALLOC_PAGES_MAX limit is treated as an exclusive limit. CUSE(3) memory maps must be less than CUSE_ALLOC_PAGES_MAX number of pages. Reviewed by: kib @ Differential Revision: https://reviews.freebsd.org/D11392 Sponsored by: Mellanox Technologies MFC after: 1 week Notes: svn path=/head/; revision=325362
* Add support for new cuse(3) error code, CUSE_ERR_NO_DEVICE.Hans Petter Selasky2017-10-052-1/+4
| | | | | | | | | | | | | This error code is useful when emulating Linux input event devices from userspace. PR: 218626 Submitted by: jan.kokemueller@gmail.com MFC after: 1 week Sponsored by: Mellanox Technologies Notes: svn path=/head/; revision=324320
* Minor code optimisation.Hans Petter Selasky2017-05-311-2/+2
| | | | | | | | | Avoid locking the global CUSE lock when the polling flags are zero. MFC after: 1 week Notes: svn path=/head/; revision=319355
* Prevent cuse4bsd.ko and cuse.ko from loading at the same time byHans Petter Selasky2016-09-231-0/+6
| | | | | | | | | | declaring support for the cuse4bsd interface in cuse.ko. Found by: Sergey V. Dyatko <sergey.dyatko@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=306228
* Handle IOC_VOID special case of passing an integer IOCTL argument through CUSE.Hans Petter Selasky2016-07-061-1/+1
| | | | | | | | Submitted by: Vladimir Kondratyev <wulf@cicgroup.ru> Approved by: re (gjb) Notes: svn path=/head/; revision=302381
* Make CUSE usable with platforms where the size of "unsigned long" isHans Petter Selasky2015-12-222-6/+6
| | | | | | | different from the size of a pointer. Notes: svn path=/head/; revision=292594
* Make CUSE usable with platforms where the size of "unsigned long" isHans Petter Selasky2015-12-222-3/+3
| | | | | | | different from the size of a pointer. Notes: svn path=/head/; revision=292593
* Guard against the same process being both CUSE server and client atHans Petter Selasky2015-12-221-2/+13
| | | | | | | | the same time. This can easily lead to a deadlock when destroying the character devices nodes. Notes: svn path=/head/; revision=292592
* Don't use POLLNVAL as a return value from the client side pollHans Petter Selasky2015-01-131-10/+28
| | | | | | | | | | function. Many existing clients don't understand POLLNVAL and instead relies on an error code from the read(), write() or ioctl() system call. Also make sure we wakeup any client pollers before the cuse server is closing, so they don't wait forever for an event. Notes: svn path=/head/; revision=277127
* Use existing PHOLD() and PRELE() macros.Hans Petter Selasky2014-06-241-16/+4
| | | | | | | Submitted by: kib @ Notes: svn path=/head/; revision=267825
* Initial import of character device in userspace support for FreeBSD.Hans Petter Selasky2014-05-233-0/+2040
The CUSE library is a wrapper for the devfs kernel functionality which is exposed through /dev/cuse . In order to function the CUSE kernel code must either be enabled in the kernel configuration file or loaded separately as a module. Currently none of the committed items are connected to the default builds, except for installing the needed header files. The CUSE code will be connected to the default world and kernel builds in a follow-up commit. The CUSE module was written by Hans Petter Selasky, somewhat inspired by similar functionality found in FUSE. The CUSE library can be used for many purposes. Currently CUSE is used when running Linux kernel drivers in user-space, which need to create a character device node to communicate with its applications. CUSE has full support for almost all devfs functionality found in the kernel: - kevents - read - write - ioctl - poll - open - close - mmap - private per file handle data Requested by several people. Also see "multimedia/cuse4bsd-kmod" in ports. Notes: svn path=/head/; revision=266581