Commit Graph

471 Commits

Author SHA1 Message Date
Nikolaus Rath
df499bf1ce Released 2.9.7. 2016-06-20 12:55:12 -07:00
Hendrik Brueckner
6189312b0c libfuse/fuse_daemonize: wait until daemon child process is ready (#55)
Mounting a FUSE file system remotely using SSH in combination with
pseudo-terminal allocation (-t), results in "Transport endpoint is
not connected" errors when trying to access the file system contents.

For example:

  # ssh -t root@localhost  "cmsfs-fuse /dev/disk/by-path/ccw-0.0.0190 /CMSFS"
  Connection to localhost closed.
  # ls /CMSFS
  ls: cannot access '/CMSFS': Transport endpoint is not connected

The cmsfs-fuse main program (which can also be any other FUSE file
system) calls into the fuse_main() libfuse library function.
The fuse_main() function later calls fuse_daemonize() to fork the
daemon process to handle the FUSE file system I/O.

The fuse_daemonize() function calls fork() as usual.  The child
proceeds with setsid() and then redirecting its file descriptors
to /dev/null etc.  The parent process, simply exits.

The child's functions and the parent's exit creates a subtle race.
This is seen with an SSH connection.  The SSH command above calls
cmsfs-fuse on an allocated pseudo-terminal device (-t option).

If the parent exits, SSH receives the command completion and closes
the connection, that means, it closes the master side of the
pseudo-terminal.  This causes a HUP signal being sent to the process
group on the pseudo-terminal.  At this point in time, the child might
not have completed the setsid() call and, hence, becomes terminated.
Note that fuse daemon sets up its signal handlers after fuse_daemonize()
has completed.

Even if the child has the chance to disassociate from its parent process
group to become it's own process group with setsid(), the child still
has the pseudo-terminal opened as stdin, stdout, and stderr.  So the
pseudo-terminal still behave as controlling terminal and might cause a
SIGHUP at closing the the master side.

To solve the problem, the parent has to wait until the child (the fuse
daemon process) has completed its processing, that means, has become
its own process group with setsid() and closed any file descriptors
pointing to the pseudo-terminal.

Closes: #27

Reported-by: Ofer Baruch <oferba@il.ibm.com>
Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
2016-06-20 12:50:05 -07:00
Dalvik Khertel
9448849b56 libfuse: pass security context options to kernel
Mount can be used with an "-o context=" option in order to specify a
mountpoint-wide SELinux security context different from the default context
provided by the active SELinux policy.

This is useful in order to enable users to mount multiple sshfs targets under
distinct contexts, which is my main motivation for getting this patch mainlined.

Closes: #36
2016-06-20 12:49:36 -07:00
Nikolaus Rath
a82a069c97 Released 2.9.6 2016-04-23 09:48:15 -07:00
Nikolaus Rath
8818df921d Enable subdir-objects automake option
This is recommended for forward-compatibility.
2016-01-14 10:19:12 -08:00
Nikolaus Rath
d09dbea729 Initialize padding to zero.
This should prevent some valgrind warnings.
2016-01-14 09:21:51 -08:00
Miklos Szeredi
0285462226 libfuse: fix warning mount.c:receive_fd()
Reported by Albert Berger
2015-08-12 11:53:10 +02:00
Miklos Szeredi
1fbc6e5353 libfuse: fix possible memory leak
Reported by Jose R. Guzman
2015-06-29 18:08:07 +02:00
Miklos Szeredi
6adcb719a9 Released 2.9.4 2015-05-22 11:24:02 +02:00
Miklos Szeredi
0516ee45ec libfuse: fix exec environment for mount and umount
Found by Tavis Ormandy (CVE-2015-3202).
2015-05-22 11:01:12 +02:00
Miklos Szeredi
cd757d22b4 libfuse: fix fuse_remove_signal_handlers()
to properly restore the default signal handler.

Reported by: Chris Johnson <johnsocg@gmail.com>
2015-02-26 16:58:37 +01:00
Miklos Szeredi
4e8f86d4d6 Initilaize stat buffer passed to ->getattr() and ->fgetattr()
to zero in all cases.

Reported by Daniel Iwan.
2014-07-22 06:31:23 +02:00
Miklos Szeredi
d6c284cbda libfuse: highlevel API: fix directory file handle passed to ioctl() method
Reported by Eric Biggers
2014-07-21 18:59:23 +02:00
Miklos Szeredi
60ac20d25f fusermount, libfuse: send value as unsigned in "user_id=" and "group_id="
...options.  Uids/gids larger than 2147483647 would result in EINVAL when
mounting the filesystem.  This also needs a fix in the kernel.
2014-07-21 18:59:05 +02:00
Daniel Thau
78bc1108d5 Add missing includes
This allows compiling fuse with musl.
2013-08-26 12:01:17 +02:00
Miklos Szeredi
d44bf3a4ac Released 2.9.3 2013-07-01 10:48:51 +02:00
Miklos Szeredi
014d950de7 libfuse: don't close fd if it's -1
This prevents a valgrind warning.
2013-07-01 10:18:49 +02:00
Miklos Szeredi
ddfd2d44a6 libfuse: fix multiple close of device fd
- fuse_kern_unmount closes handle (e.g. 19)
- a thread in my process opens a file - the OS assigns newly freed
handle (i.e. 19)
- fuse_kern_chan_destroy closes the same handle (i.e. 19)
- a thread in my process opens another file - the OS assigns newly
freed handle (i.e. 19)
- * MAYHEM *

Reported by Dan Greenfield
2013-07-01 10:06:37 +02:00
Miklos Szeredi
44088bc7fb libfuse: fix thread cancel race
Exiting a worker my race with cancelling that same worker.  This caused a
segmenation fault.

Reported and tested by Anatol Pomozov
2013-03-19 17:16:14 +01:00
Miklos Szeredi
22d0d4275a Add "nopath" to help. 2013-02-18 14:43:08 +01:00
Madan Valluri
d7bf78d913 libfuse: fix the 'remember' option
The lru list was not initialized for the "/" path.  This resulted in
remove_node_lru() crashing on LOOKUP-DOTDOT.

Patch by Madan Valluri.
--
 ChangeLog  |    4 ++++
 lib/fuse.c |    4 ++++
 2 files changed, 8 insertions(+)
2013-02-04 18:30:14 +01:00
Ratna_Bolla@dell.com
3a2bd4da6b libfuse: fix crash in unlock_path()
Patch by Ratna Manoj.

queue_element_unlock() should set ->first_locked and ->second_locked to false.

Discovered with 'fs_racer'.  The assert(wnode->treelock == TREELOCK_WRITE) in
unlock_path() was hit within minutes.

Miklos: simplified patch
2013-02-04 18:30:14 +01:00
Miklos Szeredi
ad38195a88 Released 2.9.2 2012-10-01 19:56:49 +02:00
Miklos Szeredi
66956b6f7a Fix deadlock in libfuse
Running "svn update" on a fuse filesystem could deadlock because of a bug in the
way the paths are locked.

Reported by Kazuaki Anami
2012-10-01 17:55:55 +02:00
Miklos Szeredi
5568aa7cd5 Fix missing config.h in buffer.c
Due to an oversight, splice will never actually be used for i/o.  Someone forgot
to #include "config.h" in lib/buffer.c (in fact almost no files include that
header).  As a result, even though configure detects splice support and puts
HAVE_SPLICE in config.h, buffer.c is always compiled as if there is no splice
support.

Also add #include "config.h" to fuse.c and fuse_lowlevel.c.  These currently
include it indirectly through fuse_misc.h, but we don't want to depend on that.

Reported by Matthew Gabeler-Lee
2012-08-24 15:18:19 +02:00
Miklos Szeredi
fdff523325 Zero out node when allocating from a slab.
Fix compile warning when not using node slab.
2012-08-14 12:16:00 +02:00
Miklos Szeredi
1061a0a2d9 Fix "fuse internal error: node NNN not found"
Commit 4dc7e675bb (Don't unhash name in FORGET) broke the forget logic in a
subtle way, resulting in "fuse internal error: node NNN not found" and causing
the filesystem daemon to abort.

Fix by incrementing the node refcount if nlookup goes from zero to one.

Reported by Kyle Lippincott
2012-08-14 11:18:07 +02:00
Miklos Szeredi
1186ccaa8d Released 2.9.1 2012-07-19 15:22:38 +02:00
Miklos Szeredi
3c4c063a2f Fix crash caused by freeing a stack address
The failure path of try_get_path2() erronously tried to free the "path1" value
(an address on the stack) instead of the allocated string pointed to by "path1".
This caused the library to crash.

Reported by Itay Perl
2012-07-19 15:05:56 +02:00
Miklos Szeredi
3b5acfac06 libfuse: mark some data constant 2012-07-04 12:19:29 +02:00
Anatol Pomozov
96ac0e5d76 Add FALLOCATE operation
fallocate filesystem operation preallocates media space for the given file.
If fallocate returns success then any subsequent write to the given range
never fails with 'not enough space' error.
2012-06-18 13:32:43 +02:00
Miklos Szeredi
384496dd02 Fix -pthread in fuse.pc
Linking to a library that uses threads requires the application to be linked
with -pthreads otherwise some pthread functions will be linked to stubs in
glibc.  So move -pthread from Libs.private to Libs in fuse.pc.

Reported by Werner Fink
2012-05-16 16:45:27 +02:00
Miklos Szeredi
2eac08be52 Add missing fuse_fs_flock to fuse_versionscript 2012-04-20 14:17:39 +02:00
Miklos Szeredi
71bfb92607 Add 'flag_utime_omit_ok' flag to fuse_operations
If the filesystem sets this flag then ->utimens() will receive UTIME_OMIT and
UTIME_NOW values as specified in utimensat(2).
2012-04-10 16:37:03 +02:00
Miklos Szeredi
6f77e7de6f Check protocol version before sending notifications
Check protocol version before sending notifications and return -ENOSYS if a
particular notification is not supported.
2012-04-10 16:01:00 +02:00
Miklos Szeredi
fd4ffa53df Interpret octal escape codes in options
Requested by Jan Engelhardt
2012-01-27 16:42:33 +01:00
Miklos Szeredi
9318a6b947 Revert "Add mmap() and munmap() methods to low level API"
This partially reverts commit 4b2157c44e.

Remove mmap/munmap suppor as this missed the interface changes for Linux-3.3
(API version 7.18).

Only revert the mmap/munmap bits and leave the retrieve_reply API fix in place
as well as the optimization in fuse_send_data_iov_fallback().
2012-01-24 14:32:28 +01:00
Anatol Pomozov
66003c2631 Disable symbol versions on MacOSX
MacOSX uses MachO binary format that does not support symbols.

This change comes from fuse4x project (fuse implementation for macosx).
2012-01-13 13:43:05 +01:00
Miklos Szeredi
6c4cc1e64d Remove unnecessary mutex unlock at the end of multithreaded event loop 2012-01-02 18:15:05 +01:00
Miklos Szeredi
3c4f7e194e Free request in fuse_reply_data()
Fix memory leak caused by a missing fuse_request_free() in fuse_reply_data().
2011-12-09 16:07:55 +01:00
Miklos Szeredi
4dc7e675bb Don't unhash name in FORGET
This resulted in ENOENT being returned for unlinked but still open files if the
kernel sent a FORGET request for the parent directory.

Discovered with fs_racer in LTP.
2011-12-09 16:07:55 +01:00
Miklos Szeredi
bfc49cefc4 Fix hang in wait_on_path()
Ville Silventoinen reported that fs_racer in LTP triggered a hang in
wait_on_path().  This bug was caused by try_get_path() not resetting "ticket" on
permanent failure.
2011-12-09 16:07:55 +01:00
Emmanuel Dreyfus
1bf98cf7bc FUSE_NODE_SLAB buildfix
When FUSE_NODE_SLAB is not defined, the build fails because of undefined
functions. Attached patch fixes the problem.
2011-12-08 13:44:19 +01:00
John Muir
5a44747054 libfuse: Notifying the kernel of deletion.
libfuse part to allow a FUSE file-system to tell the kernel when a
file or directory is deleted. If the specified dentry has the
specified inode number, the kernel will unhash it.

Signed-off-by: John Muir <john@jmuir.com>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
2011-12-07 12:23:58 +01:00
Miklos Szeredi
4b2157c44e Add mmap() and munmap() methods to low level API
Currently this is only useful for CUSE.  Also update retrieve_reply()
method.
2011-12-06 18:06:18 +01:00
Miklos Szeredi
e3f95263a7 Add support for ioctl on directories
Reported by Antonio SJ Musumeci
2011-12-05 15:21:28 +01:00
Miklos Szeredi
6b12905b10 Make lock argument of fuse_reply_lock const
Low level API: lock argument of fuse_reply_lock should have a
'const' qualifier.

Reported by Shachar Sharon
2011-12-05 13:31:42 +01:00
Miklos Szeredi
42d5c66b0b Reply with ENOMEM in case of failure to allocate request
Reply to request with ENOMEM in case of failure to allocate request
structure.  Otherwise the task issuing the request will just freeze up
until the filesystem daemon is killed.  Reported by Stephan Kulow
2011-10-23 10:07:20 +02:00
Anatol Pomozov
7728b36a83 Replace daemon() function with fork()
daemon() is a BSD-ism. Although it is available on many platforms
it is not a standard function. Some platforms (e.g. MacOSX) deprecated
it.

It is safer just to use fork() function that is a part of POSIX.
2011-09-23 13:28:51 +02:00
Miklos Szeredi
0131407f4e Don't ignore --disable-mtab
If configured with --disable-mtab then don't call mount(8) from
libfuse to update the mtab.

Reported by: James Sierp
2011-08-31 12:55:06 +02:00