Skip to content

Commit f757165

Browse files
committed
Merge tag 'fuse-fixes-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
Pull fuse fixes from Miklos Szeredi: - Fix a regression introduced in v5.1 that triggers WARNINGs for some fuse filesystems - Fix an xfstest failure - Allow overlayfs to be used on top of fuse/virtiofs - Code and documentation cleanups * tag 'fuse-fixes-5.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse: fuse: use true,false for bool variable Documentation: filesystems: convert fuse to RST fuse: Support RENAME_WHITEOUT flag fuse: don't overflow LLONG_MAX with end offset fix up iter on short count in fuse_direct_io()
2 parents 175787e + cabdb4f commit f757165

File tree

8 files changed

+104
-105
lines changed

8 files changed

+104
-105
lines changed

Documentation/filesystems/fuse.txt renamed to Documentation/filesystems/fuse.rst

Lines changed: 73 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,40 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
==============
3+
FUSE
4+
==============
5+
16
Definitions
2-
~~~~~~~~~~~
7+
===========
38

49
Userspace filesystem:
5-
610
A filesystem in which data and metadata are provided by an ordinary
711
userspace process. The filesystem can be accessed normally through
812
the kernel interface.
913

1014
Filesystem daemon:
11-
1215
The process(es) providing the data and metadata of the filesystem.
1316

1417
Non-privileged mount (or user mount):
15-
1618
A userspace filesystem mounted by a non-privileged (non-root) user.
1719
The filesystem daemon is running with the privileges of the mounting
1820
user. NOTE: this is not the same as mounts allowed with the "user"
1921
option in /etc/fstab, which is not discussed here.
2022

2123
Filesystem connection:
22-
2324
A connection between the filesystem daemon and the kernel. The
2425
connection exists until either the daemon dies, or the filesystem is
2526
umounted. Note that detaching (or lazy umounting) the filesystem
26-
does _not_ break the connection, in this case it will exist until
27+
does *not* break the connection, in this case it will exist until
2728
the last reference to the filesystem is released.
2829

2930
Mount owner:
30-
3131
The user who does the mounting.
3232

3333
User:
34-
3534
The user who is performing filesystem operations.
3635

3736
What is FUSE?
38-
~~~~~~~~~~~~~
37+
=============
3938

4039
FUSE is a userspace filesystem framework. It consists of a kernel
4140
module (fuse.ko), a userspace library (libfuse.*) and a mount utility
@@ -46,79 +45,67 @@ non-privileged mounts. This opens up new possibilities for the use of
4645
filesystems. A good example is sshfs: a secure network filesystem
4746
using the sftp protocol.
4847

49-
The userspace library and utilities are available from the FUSE
50-
homepage:
51-
52-
http://fuse.sourceforge.net/
48+
The userspace library and utilities are available from the
49+
`FUSE homepage: <http://fuse.sourceforge.net/>`_
5350

5451
Filesystem type
55-
~~~~~~~~~~~~~~~
52+
===============
5653

5754
The filesystem type given to mount(2) can be one of the following:
5855

59-
'fuse'
60-
61-
This is the usual way to mount a FUSE filesystem. The first
62-
argument of the mount system call may contain an arbitrary string,
63-
which is not interpreted by the kernel.
56+
fuse
57+
This is the usual way to mount a FUSE filesystem. The first
58+
argument of the mount system call may contain an arbitrary string,
59+
which is not interpreted by the kernel.
6460

65-
'fuseblk'
66-
67-
The filesystem is block device based. The first argument of the
68-
mount system call is interpreted as the name of the device.
61+
fuseblk
62+
The filesystem is block device based. The first argument of the
63+
mount system call is interpreted as the name of the device.
6964

7065
Mount options
71-
~~~~~~~~~~~~~
72-
73-
'fd=N'
66+
=============
7467

68+
fd=N
7569
The file descriptor to use for communication between the userspace
7670
filesystem and the kernel. The file descriptor must have been
7771
obtained by opening the FUSE device ('/dev/fuse').
7872

79-
'rootmode=M'
80-
73+
rootmode=M
8174
The file mode of the filesystem's root in octal representation.
8275

83-
'user_id=N'
84-
76+
user_id=N
8577
The numeric user id of the mount owner.
8678

87-
'group_id=N'
88-
79+
group_id=N
8980
The numeric group id of the mount owner.
9081

91-
'default_permissions'
92-
82+
default_permissions
9383
By default FUSE doesn't check file access permissions, the
9484
filesystem is free to implement its access policy or leave it to
9585
the underlying file access mechanism (e.g. in case of network
9686
filesystems). This option enables permission checking, restricting
9787
access based on file mode. It is usually useful together with the
9888
'allow_other' mount option.
9989

100-
'allow_other'
101-
90+
allow_other
10291
This option overrides the security measure restricting file access
10392
to the user mounting the filesystem. This option is by default only
10493
allowed to root, but this restriction can be removed with a
10594
(userspace) configuration option.
10695

107-
'max_read=N'
108-
96+
max_read=N
10997
With this option the maximum size of read operations can be set.
11098
The default is infinite. Note that the size of read requests is
11199
limited anyway to 32 pages (which is 128kbyte on i386).
112100

113-
'blksize=N'
114-
101+
blksize=N
115102
Set the block size for the filesystem. The default is 512. This
116103
option is only valid for 'fuseblk' type mounts.
117104

118105
Control filesystem
119-
~~~~~~~~~~~~~~~~~~
106+
==================
120107

121-
There's a control filesystem for FUSE, which can be mounted by:
108+
There's a control filesystem for FUSE, which can be mounted by::
122109

123110
mount -t fusectl none /sys/fs/fuse/connections
124111

@@ -130,53 +117,51 @@ named by a unique number.
130117

131118
For each connection the following files exist within this directory:
132119

133-
'waiting'
134-
135-
The number of requests which are waiting to be transferred to
136-
userspace or being processed by the filesystem daemon. If there is
137-
no filesystem activity and 'waiting' is non-zero, then the
138-
filesystem is hung or deadlocked.
139-
140-
'abort'
120+
waiting
121+
The number of requests which are waiting to be transferred to
122+
userspace or being processed by the filesystem daemon. If there is
123+
no filesystem activity and 'waiting' is non-zero, then the
124+
filesystem is hung or deadlocked.
141125

142-
Writing anything into this file will abort the filesystem
143-
connection. This means that all waiting requests will be aborted an
144-
error returned for all aborted and new requests.
126+
abort
127+
Writing anything into this file will abort the filesystem
128+
connection. This means that all waiting requests will be aborted an
129+
error returned for all aborted and new requests.
145130

146131
Only the owner of the mount may read or write these files.
147132

148133
Interrupting filesystem operations
149-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134+
##################################
150135

151136
If a process issuing a FUSE filesystem request is interrupted, the
152137
following will happen:
153138

154-
1) If the request is not yet sent to userspace AND the signal is
139+
- If the request is not yet sent to userspace AND the signal is
155140
fatal (SIGKILL or unhandled fatal signal), then the request is
156141
dequeued and returns immediately.
157142

158-
2) If the request is not yet sent to userspace AND the signal is not
159-
fatal, then an 'interrupted' flag is set for the request. When
143+
- If the request is not yet sent to userspace AND the signal is not
144+
fatal, then an interrupted flag is set for the request. When
160145
the request has been successfully transferred to userspace and
161146
this flag is set, an INTERRUPT request is queued.
162147

163-
3) If the request is already sent to userspace, then an INTERRUPT
148+
- If the request is already sent to userspace, then an INTERRUPT
164149
request is queued.
165150

166151
INTERRUPT requests take precedence over other requests, so the
167152
userspace filesystem will receive queued INTERRUPTs before any others.
168153

169154
The userspace filesystem may ignore the INTERRUPT requests entirely,
170-
or may honor them by sending a reply to the _original_ request, with
155+
or may honor them by sending a reply to the *original* request, with
171156
the error set to EINTR.
172157

173158
It is also possible that there's a race between processing the
174159
original request and its INTERRUPT request. There are two possibilities:
175160

176-
1) The INTERRUPT request is processed before the original request is
161+
1. The INTERRUPT request is processed before the original request is
177162
processed
178163

179-
2) The INTERRUPT request is processed after the original request has
164+
2. The INTERRUPT request is processed after the original request has
180165
been answered
181166

182167
If the filesystem cannot find the original request, it should wait for
@@ -186,7 +171,7 @@ should reply to the INTERRUPT request with an EAGAIN error. In case
186171
reply will be ignored.
187172

188173
Aborting a filesystem connection
189-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174+
================================
190175

191176
It is possible to get into certain situations where the filesystem is
192177
not responding. Reasons for this may be:
@@ -216,7 +201,7 @@ the filesystem. There are several ways to do this:
216201
powerful method, always works.
217202

218203
How do non-privileged mounts work?
219-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
204+
==================================
220205

221206
Since the mount() system call is a privileged operation, a helper
222207
program (fusermount) is needed, which is installed setuid root.
@@ -235,15 +220,13 @@ system. Obvious requirements arising from this are:
235220
other users' or the super user's processes
236221

237222
How are requirements fulfilled?
238-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
223+
===============================
239224

240225
A) The mount owner could gain elevated privileges by either:
241226

242-
1) creating a filesystem containing a device file, then opening
243-
this device
227+
1. creating a filesystem containing a device file, then opening this device
244228

245-
2) creating a filesystem containing a suid or sgid application,
246-
then executing this application
229+
2. creating a filesystem containing a suid or sgid application, then executing this application
247230

248231
The solution is not to allow opening device files and ignore
249232
setuid and setgid bits when executing programs. To ensure this
@@ -275,16 +258,16 @@ How are requirements fulfilled?
275258
of other users' processes.
276259

277260
i) It can slow down or indefinitely delay the execution of a
278-
filesystem operation creating a DoS against the user or the
279-
whole system. For example a suid application locking a
280-
system file, and then accessing a file on the mount owner's
281-
filesystem could be stopped, and thus causing the system
282-
file to be locked forever.
261+
filesystem operation creating a DoS against the user or the
262+
whole system. For example a suid application locking a
263+
system file, and then accessing a file on the mount owner's
264+
filesystem could be stopped, and thus causing the system
265+
file to be locked forever.
283266

284267
ii) It can present files or directories of unlimited length, or
285-
directory structures of unlimited depth, possibly causing a
286-
system process to eat up diskspace, memory or other
287-
resources, again causing DoS.
268+
directory structures of unlimited depth, possibly causing a
269+
system process to eat up diskspace, memory or other
270+
resources, again causing *DoS*.
288271

289272
The solution to this as well as B) is not to allow processes
290273
to access the filesystem, which could otherwise not be
@@ -294,28 +277,27 @@ How are requirements fulfilled?
294277
ptrace can be used to check if a process is allowed to access
295278
the filesystem or not.
296279

297-
Note that the ptrace check is not strictly necessary to
280+
Note that the *ptrace* check is not strictly necessary to
298281
prevent B/2/i, it is enough to check if mount owner has enough
299282
privilege to send signal to the process accessing the
300-
filesystem, since SIGSTOP can be used to get a similar effect.
283+
filesystem, since *SIGSTOP* can be used to get a similar effect.
301284

302285
I think these limitations are unacceptable?
303-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
286+
===========================================
304287

305288
If a sysadmin trusts the users enough, or can ensure through other
306289
measures, that system processes will never enter non-privileged
307-
mounts, it can relax the last limitation with a "user_allow_other"
290+
mounts, it can relax the last limitation with a 'user_allow_other'
308291
config option. If this config option is set, the mounting user can
309-
add the "allow_other" mount option which disables the check for other
292+
add the 'allow_other' mount option which disables the check for other
310293
users' processes.
311294

312295
Kernel - userspace interface
313-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
296+
============================
314297

315298
The following diagram shows how a filesystem operation (in this
316-
example unlink) is performed in FUSE.
299+
example unlink) is performed in FUSE. ::
317300

318-
NOTE: everything in this description is greatly simplified
319301

320302
| "rm /mnt/fuse/file" | FUSE filesystem daemon
321303
| |
@@ -357,12 +339,13 @@ NOTE: everything in this description is greatly simplified
357339
| <fuse_unlink() |
358340
| <sys_unlink() |
359341

342+
.. note:: Everything in the description above is greatly simplified
343+
360344
There are a couple of ways in which to deadlock a FUSE filesystem.
361345
Since we are talking about unprivileged userspace programs,
362346
something must be done about these.
363347

364-
Scenario 1 - Simple deadlock
365-
-----------------------------
348+
**Scenario 1 - Simple deadlock**::
366349

367350
| "rm /mnt/fuse/file" | FUSE filesystem daemon
368351
| |
@@ -379,12 +362,12 @@ Scenario 1 - Simple deadlock
379362

380363
The solution for this is to allow the filesystem to be aborted.
381364

382-
Scenario 2 - Tricky deadlock
383-
----------------------------
365+
**Scenario 2 - Tricky deadlock**
366+
384367

385368
This one needs a carefully crafted filesystem. It's a variation on
386369
the above, only the call back to the filesystem is not explicit,
387-
but is caused by a pagefault.
370+
but is caused by a pagefault. ::
388371

389372
| Kamikaze filesystem thread 1 | Kamikaze filesystem thread 2
390373
| |
@@ -410,7 +393,7 @@ but is caused by a pagefault.
410393
| | [lock page]
411394
| | * DEADLOCK *
412395

413-
Solution is basically the same as above.
396+
The solution is basically the same as above.
414397

415398
An additional problem is that while the write buffer is being copied
416399
to the request, the request must not be interrupted/aborted. This is

Documentation/filesystems/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Documentation for filesystem implementations.
4747
:maxdepth: 2
4848

4949
autofs
50+
fuse
5051
overlayfs
5152
virtiofs
5253
vfat

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6903,7 +6903,7 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git
69036903
S: Maintained
69046904
F: fs/fuse/
69056905
F: include/uapi/linux/fuse.h
6906-
F: Documentation/filesystems/fuse.txt
6906+
F: Documentation/filesystems/fuse.rst
69076907

69086908
FUTEX SUBSYSTEM
69096909
M: Thomas Gleixner <[email protected]>

fs/fuse/cuse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,8 @@ static int cuse_send_init(struct cuse_conn *cc)
451451
ap->args.out_args[0].size = sizeof(ia->out);
452452
ap->args.out_args[0].value = &ia->out;
453453
ap->args.out_args[1].size = CUSE_INIT_INFO_MAX;
454-
ap->args.out_argvar = 1;
455-
ap->args.out_pages = 1;
454+
ap->args.out_argvar = true;
455+
ap->args.out_pages = true;
456456
ap->num_pages = 1;
457457
ap->pages = &ia->page;
458458
ap->descs = &ia->desc;

fs/fuse/dir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ static int fuse_rename2(struct inode *olddir, struct dentry *oldent,
818818
struct fuse_conn *fc = get_fuse_conn(olddir);
819819
int err;
820820

821-
if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE))
821+
if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE | RENAME_WHITEOUT))
822822
return -EINVAL;
823823

824824
if (flags) {

0 commit comments

Comments
 (0)