Fuse Ext4

Posted on  by 

Definitions¶

This is going to be short. I write this tutorial, because a lot of tutorials mention ext4fuse. While it works for some things one experiences quite a few oddities. Examples of problems I experienced: everything has only read permissions it is possible cd into non existing directories things. Installing VirtualBox itself is fairly straightforward, and if you have an Ext4-formatted hard drive, you’re probably familiar with installing Linux. If not, read on for other options. Add Ext4 Support to macOS. If you frequently use Ext4-formatted disks and/or need to copy files from them to your macOS drive, you need a better option. Dokan FUSE (Filesystem in Userspace) is a wrapper library that makes Dokan compatible with FUSE API. You simply need to rebuild your FUSE source code without changes with Cygwin/MinGW and link against the library to make it work on Windows. # # /etc/fstab: static file system information # # UUID=49b4f420-239d-4645-9746-038b54b0f5d7 /boot ext4 relatime,defaults 0 1 UUID=dd3f343e-a123-460c-98df-aac65d6f4501 / ext4 relatime,defaults 0 1 UUID=c65aa4a1-6a8e-4118-8a8d-fc0f4eabba29 /usr ext4 relatime,defaults 0 1 UUID=a9f722f8-0914-4b1c-829a-a892a3cea7f1 /var ext4 relatime,defaults 0 1. Fuse a future such that poll will never again be called once it has completed. This method can be used to turn any Future into a FusedFuture. Normally, once a future has returned Poll::Ready from poll, any further calls could exhibit bad behavior such as blocking forever, panicking, never returning, etc.If it is known that poll may be called too often then this method can be used to ensure.

Userspace filesystem:

A filesystem in which data and metadata are provided by an ordinaryuserspace process. The filesystem can be accessed normally throughthe kernel interface.

Filesystem daemon:

The process(es) providing the data and metadata of the filesystem.

Non-privileged mount (or user mount):

A userspace filesystem mounted by a non-privileged (non-root) user.The filesystem daemon is running with the privileges of the mountinguser. NOTE: this is not the same as mounts allowed with the “user”option in /etc/fstab, which is not discussed here.

Filesystem connection:

A connection between the filesystem daemon and the kernel. Theconnection exists until either the daemon dies, or the filesystem isumounted. Note that detaching (or lazy umounting) the filesystemdoes not break the connection, in this case it will exist untilthe last reference to the filesystem is released.

Mount owner:

The user who does the mounting.

User:

The user who is performing filesystem operations.

What is FUSE?¶

FUSE is a userspace filesystem framework. It consists of a kernelmodule (fuse.ko), a userspace library (libfuse.*) and a mount utility(fusermount).

One of the most important features of FUSE is allowing secure,non-privileged mounts. This opens up new possibilities for the use offilesystems. A good example is sshfs: a secure network filesystemusing the sftp protocol.

The userspace library and utilities are available from theFUSE homepage:

Filesystem type¶

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

Fuse Ext4 Mac Os X

fuse

This is the usual way to mount a FUSE filesystem. The firstargument of the mount system call may contain an arbitrary string,which is not interpreted by the kernel.

fuseblk

The filesystem is block device based. The first argument of themount system call is interpreted as the name of the device.

Mount options¶

fd=N

The file descriptor to use for communication between the userspacefilesystem and the kernel. The file descriptor must have beenobtained by opening the FUSE device (‘/dev/fuse’).

rootmode=M

The file mode of the filesystem’s root in octal representation.

Fuse
user_id=N

The numeric user id of the mount owner.

group_id=N

The numeric group id of the mount owner.

default_permissions

By default FUSE doesn’t check file access permissions, thefilesystem is free to implement its access policy or leave it tothe underlying file access mechanism (e.g. in case of networkfilesystems). This option enables permission checking, restrictingaccess based on file mode. It is usually useful together with the‘allow_other’ mount option.

allow_other

This option overrides the security measure restricting file accessto the user mounting the filesystem. This option is by default onlyallowed to root, but this restriction can be removed with a(userspace) configuration option.

max_read=N

With this option the maximum size of read operations can be set.The default is infinite. Note that the size of read requests islimited anyway to 32 pages (which is 128kbyte on i386).

blksize=N

Set the block size for the filesystem. The default is 512. Thisoption is only valid for ‘fuseblk’ type mounts.

Control filesystem¶

There’s a control filesystem for FUSE, which can be mounted by:

Mounting it under the ‘/sys/fs/fuse/connections’ directory makes itbackwards compatible with earlier versions.

Under the fuse control filesystem each connection has a directorynamed by a unique number.

For each connection the following files exist within this directory:

waiting

The number of requests which are waiting to be transferred touserspace or being processed by the filesystem daemon. If there isno filesystem activity and ‘waiting’ is non-zero, then thefilesystem is hung or deadlocked.

abort

Writing anything into this file will abort the filesystemconnection. This means that all waiting requests will be aborted anerror returned for all aborted and new requests.

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

Interrupting filesystem operations¶

If a process issuing a FUSE filesystem request is interrupted, thefollowing will happen:

  • If the request is not yet sent to userspace AND the signal isfatal (SIGKILL or unhandled fatal signal), then the request isdequeued and returns immediately.

  • If the request is not yet sent to userspace AND the signal is notfatal, then an interrupted flag is set for the request. Whenthe request has been successfully transferred to userspace andthis flag is set, an INTERRUPT request is queued.

  • If the request is already sent to userspace, then an INTERRUPTrequest is queued.

INTERRUPT requests take precedence over other requests, so theuserspace filesystem will receive queued INTERRUPTs before any others.

The userspace filesystem may ignore the INTERRUPT requests entirely,or may honor them by sending a reply to the original request, withthe error set to EINTR.

It is also possible that there’s a race between processing theoriginal request and its INTERRUPT request. There are two possibilities:

  1. The INTERRUPT request is processed before the original request isprocessed

  2. The INTERRUPT request is processed after the original request hasbeen answered

If the filesystem cannot find the original request, it should wait forsome timeout and/or a number of new requests to arrive, after which itshould reply to the INTERRUPT request with an EAGAIN error. In case1) the INTERRUPT request will be requeued. In case 2) the INTERRUPTreply will be ignored.

Aborting a filesystem connection¶

It is possible to get into certain situations where the filesystem isnot responding. Reasons for this may be:

  1. Broken userspace filesystem implementation

  2. Network connection down

  3. Accidental deadlock

  4. Malicious deadlock

(For more on c) and d) see later sections)

In either of these cases it may be useful to abort the connection tothe filesystem. There are several ways to do this:

  • Kill the filesystem daemon. Works in case of a) and b)

  • Kill the filesystem daemon and all users of the filesystem. Worksin all cases except some malicious deadlocks

  • Use forced umount (umount -f). Works in all cases but only iffilesystem is still attached (it hasn’t been lazy unmounted)

  • Abort filesystem through the FUSE control filesystem. Mostpowerful method, always works.

How do non-privileged mounts work?¶

Since the mount() system call is a privileged operation, a helperprogram (fusermount) is needed, which is installed setuid root.

The implication of providing non-privileged mounts is that the mountowner must not be able to use this capability to compromise thesystem. Obvious requirements arising from this are:

  1. mount owner should not be able to get elevated privileges with thehelp of the mounted filesystem

  2. mount owner should not get illegitimate access to information fromother users’ and the super user’s processes

  3. mount owner should not be able to induce undesired behavior inother users’ or the super user’s processes

How are requirements fulfilled?¶

  1. The mount owner could gain elevated privileges by either:

    1. creating a filesystem containing a device file, then opening this device

    2. creating a filesystem containing a suid or sgid application, then executing this application

    The solution is not to allow opening device files and ignoresetuid and setgid bits when executing programs. To ensure thisfusermount always adds “nosuid” and “nodev” to the mount optionsfor non-privileged mounts.

  2. If another user is accessing files or directories in thefilesystem, the filesystem daemon serving requests can record theexact sequence and timing of operations performed. Thisinformation is otherwise inaccessible to the mount owner, so thiscounts as an information leak.

    The solution to this problem will be presented in point 2) of C).

  3. There are several ways in which the mount owner can induceundesired behavior in other users’ processes, such as:

    1. mounting a filesystem over a file or directory which the mountowner could otherwise not be able to modify (or could onlymake limited modifications).

      This is solved in fusermount, by checking the accesspermissions on the mountpoint and only allowing the mount ifthe mount owner can do unlimited modification (has writeaccess to the mountpoint, and mountpoint is not a “sticky”directory)

    2. Even if 1) is solved the mount owner can change the behaviorof other users’ processes.

      1. It can slow down or indefinitely delay the execution of afilesystem operation creating a DoS against the user or thewhole system. For example a suid application locking asystem file, and then accessing a file on the mount owner’sfilesystem could be stopped, and thus causing the systemfile to be locked forever.

      2. It can present files or directories of unlimited length, ordirectory structures of unlimited depth, possibly causing asystem process to eat up diskspace, memory or otherresources, again causing DoS.

      The solution to this as well as B) is not to allow processesto access the filesystem, which could otherwise not bemonitored or manipulated by the mount owner. Since if themount owner can ptrace a process, it can do all of the abovewithout using a FUSE mount, the same criteria as used inptrace can be used to check if a process is allowed to accessthe filesystem or not.

      Note that the ptrace check is not strictly necessary toprevent B/2/i, it is enough to check if mount owner has enoughprivilege to send signal to the process accessing thefilesystem, since SIGSTOP can be used to get a similar effect.

I think these limitations are unacceptable?¶

If a sysadmin trusts the users enough, or can ensure through othermeasures, that system processes will never enter non-privilegedmounts, it can relax the last limitation with a ‘user_allow_other’config option. If this config option is set, the mounting user canadd the ‘allow_other’ mount option which disables the check for otherusers’ processes.

Kernel - userspace interface¶

The following diagram shows how a filesystem operation (in thisexample unlink) is performed in FUSE.

Note

Everything in the description above is greatly simplified

There are a couple of ways in which to deadlock a FUSE filesystem.Since we are talking about unprivileged userspace programs,something must be done about these.

Scenario 1 - Simple deadlock:

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

Scenario 2 - Tricky deadlock

Fuse Ext4

This one needs a carefully crafted filesystem. It’s a variation onthe above, only the call back to the filesystem is not explicit,but is caused by a pagefault.

The solution is basically the same as above.

An additional problem is that while the write buffer is being copiedto the request, the request must not be interrupted/aborted. This isbecause the destination address of the copy may not be valid after therequest has returned.

Ext4fuse

This is solved with doing the copy atomically, and allowing abortwhile the page(s) belonging to the write buffer are faulted withget_user_pages(). The ‘req->locked’ flag indicates when the copy istaking place, and abort is delayed until this flag is unset.

Fuse Ext4fuse

No. - TypeDescription
fuse 15Amini
2
Instrument cluster
fuse 25Amini
4
Power mirrors, autolamp, remote anti-theft/keyless entry, headlamp relay and parking lamp relay
fuse 15Amini
Speed control, daytime running lamps, climate control blend door, backup lamps, A/C clutch coil
fuse 5Amini
Brake-shift interlock, generic electronic module (GEM)/central timer module (CTM) and air suspension module
fuse mini
8
Radio, remote anti-theft/keyless entry, GEM module/CTM module
fuse mini
10
Not used
fuse 30Amini
12
On-board diagnostic (OBD II) data link connector
fuse 15Amini
Brake ON/OFF switch, rear anti-lock brake module and brake pressure switch
fuse 15Amini
15
GEM module/CTM module
fuse 20Amini
17
Not used
fuse 5Amini
19
Air bag diagnostic monitor, instrument cluster
fuse 5Amini
GEM module/CTM module and powertrain control module (PCM)
fuse 15Amini
22
Air bag diagnostic monitor and passenger air bag deactivate switch
fuse 10Amini
4WD clutch relay, electronic flasher, 4WD/2WD vacuum solenoids and trailer tow battery charge relay
fuse 10Amini
25
4WABS module and relay
fuse 10Amini
27
Foglamp relay
fuse 10Amini
29
Autolamp, instrument cluster, transmission control indicator lamp and switch
fuse 30Amini
31
Not used
relay half
R2
Battery saver relay
relay full
R4
One touch down relay
relay full

Coments are closed