aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorLines
2018-10-16Bump minimum Meson versionNikolaus Rath-4/+4
According to user reports (https://github.com/libfuse/libfuse/pull/300), we need at least version 0.42.
2018-10-11Clarified licensing terms.Nikolaus Rath-0/+13
Fixes: #213.
2018-10-10Enable more tests for passthrough_llNikolaus Rath-48/+18
2018-10-10passthrough_ll: initialize unused memoryMiklos Szeredi-3/+4
For '.' and '..' entries only the file type in e.attr.st_mode and the inode number in e.attr.st_ino are used. But it's prudent to at least initialize the other fields of struct fuse_entry_param as well, instead of using random values from the stack.
2018-10-10passthrough_ll: allow configuring cachingMiklos Szeredi-8/+55
Caching can be controlled with the following options: "cache=never": disable caching "cache=normal": enable caching but also refresh after the timeout "cache=always": never refresh cache The timeout can be controlled with the "timeout=SEC" option, where SEC is the number of seconds and can be an arbitrary non-negative floating point number. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add *xattr() operationsMiklos Szeredi-0/+186
The extended attribute functionality is enabled with the "xattr" option (default) and disabled with the "no_xatt" option. New operations added: - getxattr - listxattr - setxattr - removexattr Caveat: none of these operations will work on a symbolic link, because it's difficult to implement that without races that can result in incorrect operation. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add flock()Miklos Szeredi-0/+23
Conditionally enable flock() locking on underlying filesystem, based on the flock/no_flock options. Default is "no_flock", meaning locking will be local to the fuse filesystem and won't be propagated to the filesystem passed through. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: whitespace cleanupMiklos Szeredi-6/+5
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add forget_multi()Vivek Goyal-1/+16
Add method forget_multi() to forget multiple inodes in a single message. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add source optionVivek Goyal-2/+19
Right now, passthrough_ll will use "/" as source directory for passthrough. We need more flexibility where user can specify path of directory to be passed through. Hence add an option "source=<source-dir>". Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add some of the missing operationsMiklos Szeredi-1/+324
New operations added: - mkdir - mknod - symlink - link - unlink - rmdir - rename - setattr - fsyncdir - flush - fsync - statfs - fallocate Caveats: - The utimes(2) family of syscalls will fail on symlinks on 4.18 and earlier kernels. Hoping to add support to later kernels. - The link(2) and linkat(2) system calls will fail on symlinks unless running with privileges (CAP_DAC_READ_SEARCH). Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add is_symlink to lo_inodeMiklos Szeredi-0/+3
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: set umask at startupMiklos Szeredi-0/+3
Like all the other passthrough examples. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: fix refcount for "." and ".." entriesMiklos Szeredi-7/+19
Kernel is not expecting an elevated lookup count for the "." and ".." entries when doing READDIRPLUS. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-10passthrough_ll: add locking to inode cacheMiklos Szeredi-26/+51
Otherwise it may crash when running multithreaded. Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
2018-10-09Add unprivileged option in `mount.fuse3`Mattias Nissler-34/+303
The unprivileged option allows to run the FUSE file system process without privileges by dropping capabilities and preventing them from being re-acquired via setuid / fscaps etc. To accomplish this, mount.fuse sets up the `/dev/fuse` file descriptor and mount itself and passes the file descriptor via the `/dev/fd/%u` mountpoint syntax to the FUSE file system.
2018-10-09Allow passing `/dev/fuse` file descriptor from parent processMattias Nissler-4/+48
This adds support for a mode of operation in which a privileged parent process opens `/dev/fuse` and takes care of mounting. The FUSE file system daemon can then run as an unprivileged child that merely processes requests on the FUSE file descriptor, which get passed using the special `/dev/fd/%u` syntax for the mountpoint parameter. The main benefit is that no privileged operations need to be performed by the FUSE file system daemon itself directly or indirectly, so the FUSE process can run with fully unprivileged and mechanisms like securebits and no_new_privs can be used to prevent subprocesses from re-acquiring privilege via setuid, fscaps, etc. This reduces risk in case the FUSE file system gets exploited by malicious file system data. Below is an example that illustrates this. Note that I'm using shell for presentation purposes, the expectation is that the parent process will implement the equivalent of the `mount -i` and `capsh` commands. ``` \# example/hello can mount successfully with privilege $ sudo sh -c "LD_LIBRARY_PATH=build/lib ./example/hello /mnt/tmp" $ sudo cat /mnt/tmp/hello Hello World! $ sudo umount /mnt/tmp \# example/hello fails to mount without privilege $ sudo capsh --drop=all --secbits=0x2f -- -c 'LD_LIBRARY_PATH=build/lib ./example/hello -f /mnt/tmp' fusermount3: mount failed: Operation not permitted \# Passing FUSE file descriptor via /dev/fd/%u allows example/hello to work without privilege $ sudo sh -c ' exec 17<>/dev/fuse mount -i -o nodev,nosuid,noexec,fd=17,rootmode=40000,user_id=0,group_id=0 -t fuse hello /mnt/tmp capsh --drop=all --secbits=0x2f -- -c "LD_LIBRARY_PATH=build/lib example/hello /dev/fd/17" ' $ sudo cat /mnt/tmp/hello Hello World! $ sudo umount /mnt/tmp ```
2018-09-28Add build options for utils and examplesMartin Blanchard-3/+14
Allow skipping utils build & installation (-Dutils=false) and examples build (-Dexamples=false). By default behaviour is unchanged (both are true: utils and examples get build).
2018-09-27Fix unlink errno checkScott Worley-1/+1
2018-09-20Clarify what qualifies as a "related operation" for notify_inval_entry.Nikolaus Rath-6/+13
2018-09-20Don't enable adaptive readdirplus unless fs has readdir() handler.Nikolaus Rath-5/+27
2018-09-17Do not include struct fuse_buf in struct fuse_workerNikolaus Rath-10/+9
This is only used in fuse_do_work(), so we can put it on the stack.
2018-09-17Don't special-case bulid of mount_util.c.Nikolaus Rath-11/+1
We already support out of source builds without this.
2018-08-31Released 3.2.6Nikolaus Rath-3/+8
2018-08-31Do not hardcode /etc/fuse.conf path.Nikolaus Rath-13/+33
2018-08-30Updated ChangeLog with recent changes.Nikolaus Rath-1/+8
2018-08-29return different non-zero error codes (#290)Oded Arbel-6/+15
Return different error codes from fuse_main()
2018-08-26Fix memory leak of FUSE modulesRostislav-3/+23
2018-08-26Fix invalid free of memory pointer in 'struct fuse_buf'Rostislav-1/+2
2018-08-25Make meson build scripts subprojects friendlyMartin Blanchard-12/+10
Multiple meson build scripts improvements including: * Bump meson requirement to 0.40.1 (0.40 already required) * Declare a dependency object for main library * Stop using add_global_arguments() * Various minor style fixes
2018-08-09Add bcachefs to mountpoint file system whitelistDaniel Fullmer-0/+1
2018-08-05Add FAT to mountpoint file system whitelistBenjamin Barenblat-0/+1
2018-08-05Realphabetize and re-document mountpoint file system whitelistBenjamin Barenblat-4/+6
2018-07-31Add autofs to mountpoint file system whitelistRobo Shimmer-0/+3
2018-07-25Remove unused member of 'struct fuse_dh'Rostislav Skudnov-1/+0
2018-07-24Released 3.2.5Nikolaus Rath-3/+12
2018-07-24Added ChangeLog entry for hardening patches.Nikolaus Rath-2/+6
2018-07-23test_write_cache: Use fuse_session_exit() to stop filesystem threadRostislav Skudnov-2/+3
Using fuse_session_exit() followed by fuse_session_unmount() ensures that a proper cleanup and shutdown is performed.
2018-07-23example/{hello,null}: Fix memory leaksRostislav Skudnov-1/+8
2018-07-23test_write_cache: Fix memory leaksRostislav Skudnov-0/+3
2018-07-23fusermount: Fix memory leaksRostislav Skudnov-0/+2
2018-07-21Fix readdir() bug when a non-zero offset is specified in filler (#269)Rostislav-11/+84
The bug occurs when a filesystem client reads a directory until the end, seeks using seekdir() to some valid non-zero position and calls readdir(). A valid 'struct dirent *' is expected, but NULL is returned instead. Pseudocode demonstrating the bug: DIR *dp = opendir("some_dir"); struct dirent *de = readdir(dp); /* Get offset of the second entry */ long offset = telldir(dp); /* Read directory until the end */ while (de) de = readdir(de); seekdir(dp, offset); de = readdir(dp); /* de must contain the second entry, but NULL is returned instead */ The reason of the bug is that when the end of directory is reached, the kernel calls FUSE_READDIR op with an offset at the end of directory, so the filesystem's .readdir callback never calls the filler function, and we end up with dh->filled set to 1. After seekdir(), FUSE_READDIR is called again with a new offset, but this time the filesystem's .readdir callback is never called, and an empty reply is returned. Fix by setting dh->filled to 1 only when zero offsets are given to filler function.
2018-07-18fusermount: whitelist known-good filesystems for mountpointsJann Horn-1/+49
Before: $ _FUSE_COMMFD=1 priv_strace -s8000 -e trace=mount util/fusermount3 /proc/self/fd mount("/dev/fuse", ".", "fuse", MS_NOSUID|MS_NODEV, "fd=3,rootmode=40000,user_id=379777,group_id=5001") = 0 sending file descriptor: Socket operation on non-socket +++ exited with 1 +++ After: $ _FUSE_COMMFD=1 priv_strace -s8000 -e trace=mount util/fusermount3 /proc/self/fd util/fusermount3: mounting over filesystem type 0x009fa0 is forbidden +++ exited with 1 +++ This patch could potentially have security impact on some systems that are configured with allow_other; see https://launchpad.net/bugs/1530566 for an example of how a similar issue in the ecryptfs mount helper was exploitable. However, the FUSE mount helper performs slightly different security checks, so that exact attack doesn't work with fusermount; I don't know of any specific attack you could perform using this, apart from faking the SELinux context of your process when someone's looking at a process listing. Potential targets for overwrite are (looking on a system with a 4.9 kernel): writable only for the current process: /proc/self/{fd,map_files} (Yes, "ls -l" claims that you don't have write access, but that's not true; "find -writable" will show you what access you really have.) writable also for other owned processes: /proc/$pid/{sched,autogroup,comm,mem,clear_refs,attr/*,oom_adj, oom_score_adj,loginuid,coredump_filter,uid_map,gid_map,projid_map, setgroups,timerslack_ns}
2018-07-18fusermount: refuse unknown optionsJann Horn-1/+7
Blacklists are notoriously fragile; especially if the kernel wishes to add some security-critical mount option at a later date, all existing systems with older versions of fusermount installed will suddenly have a security problem. Additionally, if the kernel's option parsing became a tiny bit laxer, the blacklist could probably be bypassed. Whitelist known-harmless flags instead, even if it's slightly more inconvenient.
2018-07-18fusermount: bail out on transient config read failureJann Horn-0/+9
If an attacker wishes to use the default configuration instead of the system's actual configuration, they can attempt to trigger a failure in read_conf(). This only permits increasing mount_max if it is lower than the default, so it's not particularly interesting. Still, this should probably be prevented robustly; bail out if funny stuff happens when we're trying to read the config. Note that the classic attack trick of opening so many files that the system-wide limit is reached won't work here - because fusermount only drops the fsuid, not the euid, the process is running with euid=0 and CAP_SYS_ADMIN, so it bypasses the number-of-globally-open-files check in get_empty_filp() (unless you're inside a user namespace).
2018-07-18fusermount: don't feed "escaped commas" into mount optionsJann Horn-1/+4
The old code permits the following behavior: $ _FUSE_COMMFD=10000 priv_strace -etrace=mount -s200 fusermount -o 'foobar=\,allow_other' mount mount("/dev/fuse", ".", "fuse", MS_NOSUID|MS_NODEV, "foobar=\\,allow_other,fd=3,rootmode=40000,user_id=1000,group_id=1000") = -1 EINVAL (Invalid argument) However, backslashes do not have any special meaning for the kernel here. As it happens, you can't abuse this because there is no FUSE mount option that takes a string value that can contain backslashes; but this is very brittle. Don't interpret "escape characters" in places where they don't work.
2018-07-18fusermount: prevent silent truncation of mount optionsJann Horn-3/+20
Currently, in the kernel, copy_mount_options() copies in one page of userspace memory (or less if some of that memory area is not mapped). do_mount() then writes a null byte to the last byte of the copied page. This means that mount option strings longer than PAGE_SIZE-1 bytes get truncated silently. Therefore, this can happen: user@d9-ut:~$ _FUSE_COMMFD=10000 fusermount -o "$(perl -e 'print ","x4000')" mount sending file descriptor: Bad file descriptor user@d9-ut:~$ grep /mount /proc/mounts /dev/fuse /home/user/mount fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1000 0 0 user@d9-ut:~$ fusermount -u mount user@d9-ut:~$ _FUSE_COMMFD=10000 fusermount -o "$(perl -e 'print ","x4050')" mount sending file descriptor: Bad file descriptor user@d9-ut:~$ grep /mount /proc/mounts /dev/fuse /home/user/mount fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=100 0 0 user@d9-ut:~$ fusermount -u mount user@d9-ut:~$ _FUSE_COMMFD=10000 fusermount -o "$(perl -e 'print ","x4051')" mount sending file descriptor: Bad file descriptor user@d9-ut:~$ grep /mount /proc/mounts /dev/fuse /home/user/mount fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=10 0 0 user@d9-ut:~$ fusermount -u mount user@d9-ut:~$ _FUSE_COMMFD=10000 fusermount -o "$(perl -e 'print ","x4052')" mount sending file descriptor: Bad file descriptor user@d9-ut:~$ grep /mount /proc/mounts /dev/fuse /home/user/mount fuse rw,nosuid,nodev,relatime,user_id=1000,group_id=1 0 0 user@d9-ut:~$ fusermount -u mount I'm not aware of any context in which this is actually exploitable - you'd still need the UIDs to fit, and you can't do it if the three GIDs of the process don't match (in the case of a typical setgid binary), but it does look like something that should be fixed. I also plan to try to get this fixed on the kernel side.
2018-07-11Released 3.2.4Nikolaus Rath-4/+8
2018-07-11Don't assume sub-second resolution for st_atime/st_mtime.Nikolaus Rath-2/+2
Fixes: #224
2018-07-04Use triple quotes for multiline string.Nikolaus Rath-2/+2
Single quotes will become an error in a future meson release.