|
|
Log in / Subscribe / Register

Trust in and maintenance of filesystems

By Jonathan Corbet
November 21, 2023

Maintainers Summit
The Linux kernel supports a wide variety of filesystems, many of which are no longer in heavy use — or, perhaps, any use at all. The kernel code implementing the less-popular filesystems tends to be relatively unpopular as well, receiving little in the way of maintenance. Keeping old filesystems alive does place a burden on kernel developers, though, so it is not surprising that there is pressure to remove the least popular ones. At the 2023 Kernel Maintainers Summit, the developers talked about these filesystems and what can be done about them.

Christoph Hellwig started the discussion by saying that it is hard for developers to know how mature — how trustworthy and maintained — any given filesystem is; that can often only be determined by talking to its users. This information gap can be a bad thing, he said. User space (in the form of desktop environments in particular) has a strong urge to automatically mount filesystems, even those that are unmaintained, insecure, and untrustworthy. This automounting exposes the system to security threats and is always a bad idea, but it's a fact of life; maybe there needs to be a way for the kernel to indicate to user space that some filesystems are not suitable for mounting in this way.

[Christoph
Hellwig] Another problem, he said, is fuzz testing. He appreciates all of the work that is going into fuzz-testing of filesystems, but it is not helpful if it is being directed at filesystems that are not going to be fixed. That is a waste of resources; the fuzzer should, instead, be directed at filesystems that will be fixed in response to problem reports.

The broader question, he continued, is how the kernel can do better at getting rid of old and unmaintained code. The process for doing so is always "very ad hoc"; typically, some maintainer gets angry and sends a removal patch, which is sometimes accepted. What comes next is typically a round of "whining in the Linux press". Other projects have "reasonable deprecation schedules", where features are annotated as being set for removal in a couple of releases unless somebody who cares puts in the time to maintain them properly. The kernel, perhaps, could benefit from something similar.

He closed by mentioning the prospect of the European Cyber Resilience Act, which could put vendors of products containing the kernel at risk.

Steve Rostedt said that, since most users run the kernels provided by distributors, the right thing to do might be to educate those distributors about which filesystems are trustworthy. Hellwig responded that, if the community needs to educate in that way, it is doing something wrong; there should be a better way to communicate this information. Ted Ts'o said that there are hundreds of distributions out there; it would be necessary for the kernel community to decide which ones it cares about. It could be said, he suggested, that distributors that do not contribute back to the kernel do not matter.

Linus Torvalds responded that he does not want anybody who would make that argument as a developer on his kernel — a position that has not changed in decades, he said. Any approach that says "users don't matter" is wrong, he said. Hellwig answered that users need to know when a filesystem is broken. Dave Chinner suggested that the right approach is to talk to the people who are setting the automounting policies — and the GNOME developers in particular.

Communications

Kees Cook said that the maturity information for filesystems could be stored as a field in the MAINTAINERS file; noises in the room made it clear that this idea was not universally loved. Hellwig said that file is not the place to send users; perhaps, instead, the automounter could be taught to only mount filesystems at a given maturity level or above. Chinner noted that the XFS developers have shipped a udev rule saying "don't automount XFS filesystems" for some time; perhaps that policy should be centralized. Torvalds said that everybody agrees that the current "automount everything" policy is wrong, but it should not be blocked in the kernel; this is a problem for the desktop environments.

Ts'o said that the problem comes down to communications; end users do not read kernel configurations or documentation folders. There is also no agreement on the acceptable level of risk; kernel developers worry about unmaintained filesystems, but GNOME developers think that everything should be automounted. That was a rule made by a product manager, he said, "and you don't argue with product managers". That, in turn, makes his life miserable as he is inundated with syzbot reports for crashes resulting from mounting malicious filesystems. The kernel, he concluded, should suggest a default policy that makes sense, but user space will make the decision.

If we had some sort of filesystem maturity model, Hellwig said, distributors would be able to use it to set an automounting policy. Josef Bacik said that it was just necessary to figure out a way to communicate this information to user space. Once that is in place, it's just a matter of waiting a couple of years for the tooling to be updated. He added that the more interesting problem was that of deprecation; there is no policy for doing that now. He would like a way to tag kernel features as being deprecated and slated for future removal. Greg Kroah-Hartman pointed out that this idea has been tried in the past (it was abandoned in 2012); Bacik said that it was time to try again.

Kroah-Hartman said that the kernel drops drivers all the time, and that perhaps the process should be formalized. Torvalds answered that he will always require a reason to deprecate code; the lack of reasons has annoyed him in the filesystem discussion, he said. He raised the "sysv" filesystem (used on Unix version 7 on PDP-11 machines and on some early proprietary x86 Unix systems) as an example; it is simple and places no burden on developers, so there is no reason to deprecate it. Bacik responded that there is no way to make changes to sysv and be sure of not breaking it; when Torvalds asked if anybody had encountered a problem with sysv, the answer from the room was "we don't know". He said that proved the lack of a cost, so nobody cares if sysv remains in the tree.

There was a side discussion on the differences between filesystems and drivers that started when Torvalds pointed out that there are many drivers in the kernel that receive little or no testing. Hellwig asserted that there are many drivers that have not worked for years. Kroah-Hartman said that there is no difference between drivers and filesystems, but Arnd Bergmann said that, for drivers, it's relatively clear when the associated hardware no longer exists. That is not the case for filesystems. Thomas Gleixner added that, if a driver stops working, it simply stops; a filesystem, instead, can silently corrupt data. Chinner agreed, pointing out that one cannot fix filesystem corruption with a reboot.

Rostedt claimed that it is possible to test all of the filesystems in the tree, since there is no special hardware needed, but the filesystem developers disagreed. Chinner said that, without a mkfs tool, filesystem testing cannot be done; additionally, there is a need for a filesystem checker and integration with the fstests suite. Ts'o singled out the ntfs filesystem; the tools are proprietary, but the kernel developers took the kernel code without insisting that the tools be open.

According to Chinner, the quality of the kernel's filesystem implementations has improved greatly over the last decade or so. There are something like 2,000 tests in the fstests suite; it even has 200 Btrfs-specific tests, where recently there were none. The reliability of the filesystems covered by fstests has gone way up; developers know that the filesystems are good and can tell users so. For the other filesystems, nobody really knows.

Torvalds pointed out that one of those other filesystems, reiserfs, is in fact deprecated and on its way out. It is possible to remove code that causes problems, but only if there is a good reason to do so. Reiserfs may still have a few users, given that SUSE defaulted to it for years, but he is happy to remove it — as long as there are no complaints, which might cause him to reconsider. Brauner asked for a proper path toward that removal, so that maintainers can effect removals without getting yelled at.

There was some discussion of how to communicate filesystem maturity information to user space. Ideas included an ELF section in module binaries, a kernel-configuration option, an interface for automounters, tainting the kernel when a low-quality filesystem is mounted, or requiring a special "I know it's deprecated" mount option. Dave Airlie suggested working with the udisks developers; Chinner said that he had tried that and "hit a brick wall" before just adding a udev rule instead. A few developers expressed frustration with a perceived inability to get a response from user-space developers on topics like this.

"Print a warning"

Torvalds said that there is no way to communicate this information to existing user space, since that code is not prepared to receive that message. Instead, he said, just outputting a warning with printk() can be effective; users see the errors and complain to their distributors. Suitable warnings could be added to the more questionable filesystems.

That, Kroah-Hartman said, requires coming up with a list of good and bad filesystems. Hellwig said that there would need to be at least three levels: "no trust", "generally maintained but don't mount untrusted images", and "well maintained". Torvalds said that this information could be given to the kernel when a filesystem is registered, and a warning printed if an untrusted filesystem is mounted. "Enough arguing", he said, it was time to just write a patch and try it.

The arguing was not done quite yet, though; Gleixner complained about architectures that do not keep up with low-level core-kernel changes. That leaves him having to figure out how to fix "25 PowerPC subarchitectures", an impossible task for a developer without the hardware and who is not an expert in that architecture. Might there be a way to tell architecture maintainers that they need to move forward to current APIs or the support will be removed?

Hellwig concurred with the problem, saying that there is an implicit assumption in the community that this sort of API cleanup is a low-priority task; as a result it is easily blocked. There needs to be a way to force developers to move to newer APIs. Bergmann mentioned the desire to remove high memory, but 32-bit Arm still needs it, so it cannot be removed from anywhere, imposing significant costs on the kernel as a whole. Chinner complained that increasing amounts of work are being placed on maintainers to keep old code working; maintainers are at the limit of what they can do now, and this path is unsustainable, he said.

Torvalds repeated that it is possible to deprecate old code when there is a good reason to do so. When Gleixner again said that he cannot get architecture maintainers to move to new APIs, Torvalds added that kernel developers often add new APIs alongside old ones to avoid having to fix everything at the outset. Perhaps, he said, developers should try to avoid that approach and, instead, just fix everything right away. Gleixner said that, for some changes, every subarchitecture must be fixed manually, which is a huge job.

Christian Brauner said that he had similar problems with the adoption of the new mount API; it took years to convert a majority of the important filesystems, and he had to do a lot of the work himself. A lot of his patches were rejected, creating a frustrating situation. Hellwig added that, during this conversion, two more filesystems using the old API were merged. Torvalds suggested that, in many of these cases, adding a warning might be all that is needed to put pressure on maintainers to move forward.

The above discussion was supposed to fit into a 30-minute discussion slot; readers who have gotten this far will be unsurprised to learn that it ran significantly over. At this point, the developers were in need of a break, so this topic was put aside so that the rest of the agenda could be addressed.

Index entries for this article
KernelFilesystems/Deprecation policy
ConferenceKernel Maintainers Summit/2023


to post comments

Trust in and maintenance of filesystems

Posted Nov 21, 2023 15:46 UTC (Tue) by willy (subscriber, #9762) [Link]

sysv will impose costs on me as part of the folio transition. I'm glad to hear it's not necessary to test it.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 16:25 UTC (Tue) by brauner (subscriber, #109349) [Link]

Just to clarify the conversion to the new mount api was a joint effort. There were a bunch of filesystems done by David and Al and then I did a few more recently. But we also have Ian working on converting a few more. So this really is collective work.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 17:00 UTC (Tue) by kees (subscriber, #27264) [Link] (1 responses)

> at least three levels: "no trust", "generally maintained but don't mount untrusted images", and "well maintained"

I had said at the start of the discussion that the information is ALREADY in the MAINTAINERS file (not that we could put it there: it's already there). If the point is that bugs go unaddressed, nothing new is needed beyond plumbing it to warnings or module metadata. Either it's orphaned or it's not:

SYSV FILESYSTEM
S: Orphan

NTFS FILESYSTEM
S: Supported

Trust in and maintenance of filesystems

Posted Nov 26, 2023 16:49 UTC (Sun) by patrakov (subscriber, #97174) [Link]

The real question is whether insurance companies (e.g. AXA) would agree with these assessments when selling cyber insurance, or override them with their own judgment.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 17:10 UTC (Tue) by ebassi (subscriber, #54855) [Link] (76 responses)

> There is also no agreement on the acceptable level of risk; kernel developers worry about unmaintained filesystems, but GNOME developers think that everything should be automounted.

I must have missed the memo in the secret GNOME cabal, because I don't remember ever discussing this particular bit of policy.

Of course, if the Linux kernel developers don't even know which file systems are safe, how is user space even remotely going to be qualified to make that decision? After all, it's usually us who get a bug filed with "I can't access my USB drive when I plug it in, GNOME sucks".

> when Torvalds asked if anybody had encountered a problem with sysv, the answer from the room was "we don't know". He said that proved the lack of a cost, so nobody cares if sysv remains in the tree.

This is horrific. The idea that dead/untested/untrusted code has no cost is… I have no words.

> A few developers expressed frustration with a perceived inability to get a response from user-space developers on topics like this.

This was the idea of the Plumbers conference, before it became yet another Linux kernel conference.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 18:29 UTC (Tue) by Wol (subscriber, #4433) [Link] (5 responses)

> > when Torvalds asked if anybody had encountered a problem with sysv, the answer from the room was "we don't know". He said that proved the lack of a cost, so nobody cares if sysv remains in the tree.

> This is horrific. The idea that dead/untested/untrusted code has no cost is… I have no words.

Point is, it's no cost to the developers. If there are no users, there are no bug reports, and nobody has to do anything.

What they should do, imho, is flag this stuff as "unsupported, deprecated, not built by default". That way, it can wither on the vine until people complain that "it's stopped working". A fix to the build system to say "default no, deprecated" is a lot easier than a fix to delete it.

Cheers,
Wol

Trust in and maintenance of filesystems

Posted Nov 22, 2023 20:25 UTC (Wed) by khim (subscriber, #9252) [Link] (4 responses)

> Point is, it's no cost to the developers. If there are no users, there are no bug reports, and nobody has to do anything.

It doesn't work like that. If there are no legitimate users there would be no bug reports.

If all the users of sysv filesystem are crackers who use to steal industrial secrets then there would be no bugreports, but that doesn't mean it's Ok to keep that code sitting there.

I'm actually surprised that no one raises the question of drivers that are unmaintained: pretending that you are some kind of strange USB gizmo is not hard, one may just use calculator for that, no need to buy a dedicated hardware, so why there are so much discussion about hostile filesystems and not about other hostile hardware?

> What they should do, imho, is flag this stuff as "unsupported, deprecated, not built by default". That way, it can wither on the vine until people complain that "it's stopped working". A fix to the build system to say "default no, deprecated" is a lot easier than a fix to delete it.

For that to make sense default kernel config needs to be a bit closer to what distros use. Currently default kernel config is not related to what distros ship at all. Maybe that need to be fixed, too.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 20:29 UTC (Wed) by pizza (subscriber, #46) [Link] (3 responses)

> Currently default kernel config is not related to what distros ship at all. Maybe that need to be fixed, too.

Yeah, general-purpose distros turn on pretty much everything, because one never knows what hardware (or filesystems, or netfilter stuff, etc) the user will have/want. That used to be considered a good thing...

Trust in and maintenance of filesystems

Posted Nov 22, 2023 21:55 UTC (Wed) by farnz (subscriber, #17727) [Link]

Against that, having built a kernel with a huge number of modules, general-purpose distros often then package the modules in "sensible" chunks; for example, Fedora splits into kernel-modules and kernel-modules-extra, where "most" users don't need the latter.

Trust in and maintenance of filesystems

Posted Nov 26, 2023 16:55 UTC (Sun) by patrakov (subscriber, #97174) [Link] (1 responses)

The CIS benchmark actually requires the user to disable some filesystems. The automated check (which is what auditors and security companies use), unfortunately, requires that they are disabled in this particular way, or you won't get a free pass:

Audit:
Run the following commands and verify the output is as indicated:
# modprobe -n -v udf
install /bin/true
# lsmod | grep udf
<No output>

Remediation:
Edit or create a file in the /etc/modprobe.d/ directory ending in .conf
Example: vim /etc/modprobe.d/udf.conf
and add the following line:
install udf /bin/true
Run the following command to unload the udf module:
# rmmod udf

Trust in and maintenance of filesystems

Posted Dec 7, 2023 17:18 UTC (Thu) by Hello71 (guest, #103412) [Link]

That's actually a reasonable way to disable one filesystem though. The problem with CIS isn't their commands (usually), it's their whack-a-mole checklist bandwagon methodology. For example, it says to "disable secure redirects" by setting secure_redirects=0, but that actually disables redirect security checks, i.e. enables insecure redirects. They do also recommend setting accept_redirects=0 which actually does disable redirects, including secure redirects. So, their recommendation doesn't actually reduce security in this scenario, but it indicates that they don't have any idea what's actually going on, they just apply "security settings". Similarly, for filesystems, a correct approach (for servers at least) would be "disable automounting and only mount trusted disks", but that's hard to sell as a magic security script.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 18:46 UTC (Tue) by MarcB (subscriber, #101804) [Link] (18 responses)

> Of course, if the Linux kernel developers don't even know which file systems are safe, how is user space even remotely going to be qualified to make that decision ...

My impression is that the answer simply is: none are. If plain fuzzing is able to trigger bugs, even in the fully maintained filesystems, it is a given that smart/dedicated attackers can do so as well. Trying to come up with any maturity rating seems like a pointless guessing game.

So the user space policy should be quite clear: Auto-Mount as little as possible. Ideally, only FUSE file systems that run as the currently logged in desktop user.
Anything beyond that should require explicit configuration. In practice, anything more complex than VFAT will require some explicitly configured UID/GID mapping anyway, so it usually makes no sense to plug in a random disk. (And if it is a disk you are constantly using, then add it to fstab or create a mount unit).

Trust in and maintenance of filesystems

Posted Nov 21, 2023 18:56 UTC (Tue) by ebassi (subscriber, #54855) [Link] (15 responses)

> My impression is that the answer simply is: none are.

Then we can pack up, and go home.

> So the user space policy should be quite clear: Auto-Mount as little as possible.

You just said that no file system is safe, so "as little as possible" also means "don't mount the USB key I just plugged into my computer", which is going to go down like a lead balloon as soon as somebody installs Linux on their machine.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 19:58 UTC (Tue) by MarcB (subscriber, #101804) [Link] (8 responses)

> Then we can pack up, and go home.

As far as kernel filesystems go: It looks that way - unless someone is actually able to come up with a reliable list of secure file systems that still has meaningful overlap with actually used file systems. This seems unlikely.

> You just said that no file system is safe, so "as little as possible" also means "don't mount the USB key I just plugged into my computer",...

Which is why I mentioned (non-root) FUSE. The should easily be able to handle the USB key use case (which is the only use case that really works out-of-the-box anyway, because of the UID/GID mapping issue).

Trust in and maintenance of filesystems

Posted Nov 21, 2023 23:36 UTC (Tue) by ebassi (subscriber, #54855) [Link] (7 responses)

> Which is why I mentioned (non-root) FUSE.

Sure, let's go with FUSE… except you don't get things like file monitoring on FUSE: https://github.com/libfuse/libfuse/issues/328

The FUSE2 vs FUSE3 situation is also still kind of problematic, with some stuff depending on one major version and conflicting with the other.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 10:00 UTC (Wed) by DemiMarie (subscriber, #164188) [Link] (5 responses)

FUSE is the supported and safe solution.

It is quite clear that upstream filesystem developers simply do not have the resources to fix all of the bugs found by fuzzers. There are too many vulnerabilities and not enough people to fix them. Darrick J. Wong literally burned out over this.

If GNOME needs to support mounting untrusted filesystem images, then it also needs to be responsible for fixing security problems that require malicious filesystems to exploit. Otherwise users will continue to be in danger.

I recommend spawning a separate virtual machine for each filesystem. This is what libguestfs does, and it is the only reasonably secure approach.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 13:20 UTC (Wed) by pizza (subscriber, #46) [Link] (2 responses)

> If GNOME needs to support mounting untrusted filesystem images, then it also needs to be responsible for fixing security problems that require malicious filesystems to exploit. Otherwise users will continue to be in danger.

s/GNOME/Linux/

Fixed that for you.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 16:17 UTC (Wed) by DemiMarie (subscriber, #164188) [Link] (1 responses)

I really did mean GNOME. Filesystem maintainers have stated that they do not have enough time to fix all the bugs found by fuzzing. If fixing these bugs is important to GNOME, then GNOME needs to either do the work or persuade someone else (Red Hat?) to do so.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 17:33 UTC (Wed) by pizza (subscriber, #46) [Link]

Let me quote you: "If GNOME needs to support mounting untrusted filesystem images, [...] "

Note the lack of "auto-" preceding "mounting"

If the problem is the auto-mounting of filesystem images, then GNOME can do something about it. However, the problem is deeper than that, and is a property of the underlying operating system (ie Linux). So whether or not GNOME auto-mounts a malicious filesystem, or the user manually mounts the malicious filesystem [1], the problem remains.

I shouldn't have to point out that "mounting user-supplied filesystem images" is something that every non-toy system has to support as a basic, essential feature. Every phone, every desktop system, and pretty much everything with a USB port. [2]

You are blaming GNOME for a problem that lies outside its purview. Should GNOME developers also be on the hook to fix buggy binary-only display drivers, or should they be able to rely on the promises those drivers make by claiming to support, say, OpenGL ES 3.2?

[1] "Of course I want to access that USB stick, it's why I plugged it in!"
[2] As it turns out, I can crash my car's radio by plugging in a well-formed filesystem that contains "too many" files.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 21:23 UTC (Wed) by Conan_Kudo (subscriber, #103240) [Link] (1 responses)

FUSE is not a reasonable solution because virtually no Linux filesystems have actively maintained FUSE ports with parity to their in-kernel versions. An interesting solution would be to mainline the Linux Kernel Library project, which would allow all the in-kernel filesystems to be easily built as FUSE modules and run from user-space. We could then ship both variants and switch between them based on the trust domain of the storage itself.

Currently, it looks like the LKL code is based on Linux kernel 6.1. Maybe someone who is interested in this can talk to them and help shepherd it into mainline.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 4:05 UTC (Thu) by DemiMarie (subscriber, #164188) [Link]

libguestfs solves this by doing the mount in a virtual machine.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 12:56 UTC (Wed) by MarcB (subscriber, #101804) [Link]

> Sure, let's go with FUSE… except you don't get things like file monitoring on FUSE: https://github.com/libfuse/libfuse/issues/328

This should not matter for the USB key use case. Everything else is so exotic that I cannot see how it justifies exposing everyone to this attack vector.
If I want to use an external XFS filesystem (which is something I actually do), I can be bothered to configure this in fstab.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 14:16 UTC (Wed) by smoogen (subscriber, #97) [Link]

>> My impression is that the answer simply is: none are.

> Then we can pack up, and go home.

I was told for the last 40 years, that it is generally impossible to make a 'general usage' filesystem 'safe' because of various 'logical paradoxes' ranging from Byzantine general to the halting problem. 'safe' is in quotes because you generally 'safe' filesystems come up with their own definition of safety which removes various 'freedoms' which open up the 'Devil's computer': 'the filesystem can't be removed or added after hardware initiation' , 'the filesystem has an outside of the operating system protector', etc. These usually remove the ability to use it in a 'general' purpose method versus a specialized method. And generally each of those descriptions also have 'methods of use' which if violated remove the 'safety'. AKA the system also assumes the drive which can't be removed or added after hardware initiation also can never be touched outside of the system (or that specific magnetic or electric fields won't be applied to it etc.)

In the end, this is no different than waking up every morning. There are thousands of things which could cause us to end up in an unsafe condition of varying amounts. We have thus engineered our civilizations to put in lots of recovery methods to various extents, and usually that is enough to make us able to function the rest of the day. We have to engineer our systems in a similar method.

Trust in and maintenance of filesystems

Posted Nov 27, 2023 10:59 UTC (Mon) by DemiMarie (subscriber, #164188) [Link] (4 responses)

One option might be to rewrite the kernel filesystem implementations in safe Rust. That should reduce the stream of vulnerabilities to a trickle, and I expect most of the remaining vulnerabilities to be denial of service only.

Otherwise, the only safe solution is FUSE with a strong sandbox around the driver. You can use libguestfs to mount any filesystem supported by Linux in a tightly sandboxed VM.

Trust in and maintenance of filesystems

Posted Nov 27, 2023 12:09 UTC (Mon) by ojeda (subscriber, #143370) [Link]

Regarding Rust, I mentioned the idea of writing safe, read-only filesystems to a few people at LPC interested in experimenting with kernel Rust, using Wedson's recently posted VFS abstractions. It would be interesting to see common filesystems implemented with those, even if read-only.

Trust in and maintenance of filesystems

Posted Nov 27, 2023 18:01 UTC (Mon) by mathstuf (subscriber, #69389) [Link] (2 responses)

> That should reduce the stream of vulnerabilities to a trickle, and I expect most of the remaining vulnerabilities to be denial of service only.

Rust isn't going to do anything about lying disks unless their expectations are encoded in the type system in some way (e.g., an `inode` or `extent` object cannot be constructed unless its extents or sizes are verified as on-disk valid). That sounds terrible for performance if you ask me. It also does nothing to handle actively malicious hardware that changes data behind the kernel's back (any verification done basically becomes a TOCTOU in this situation…I don't see how it's possible to win here either). It'll fix buffer overflows (so if an extent metadata pointer has a mismatched size or something), but I don't think that's the kind of worry that is casting the shadow that is worried about here.

Trust in and maintenance of filesystems

Posted Nov 27, 2023 18:58 UTC (Mon) by farnz (subscriber, #17727) [Link] (1 responses)

I think part of the fun here is deciding on what the threat model is; mine requires that the filesystem cannot be exploited to do anything other than read arbitrary blocks from the underlying block device, and write data that's deliberately written to the filesystem to blocks on the underlying block device (including metadata like updating mount counters). This has two corollaries:

  1. A malicious storage device can only exploit the filesystem implementation to read or write other data on the same storage device. However, an entity creating such a storage device already has full access to read all the data on the device, and it's not on the filesystem implementation to prevent me writing interesting things to a device I can't trust.
  2. A crafted filesystem image can, at worst, result in creeping corruption of that filesystem, and not in damage to other filesystems on different storage devices, or even in different partitions on the same underlying device.

This is a threat model that isn't met by most in-kernel filesystems today - a suitably corrupt filesystem image on a non-malicious storage medium could, in principle, exploit the filesystem to the point of arbitrary code execution, which implies that a malicious storage device can do the same. In theory, a safe Rust filesystem implementation could meet my threat model, by parsing the filesystem, and ensuring that if the parsed data is crazy, the implementation errors out rather than overflowing a buffer or similar.

Trust in and maintenance of filesystems

Posted Dec 10, 2023 3:15 UTC (Sun) by SAI_Peregrinus (guest, #151778) [Link]

I agree with this threat model.

It doesn't matter much if a filesystem can corrupt itself, as long as it can't corrupt the rest of the user's data. It matters a lot if a filesystem can corrupt the user's data on other filesystems.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 4:40 UTC (Wed) by dxld (subscriber, #90530) [Link] (1 responses)

> only FUSE file systems that run as the currently logged in desktop user.

I just want to point out that there's not much of a difference between root and the desktop user on a single-user machine. A rogue FS triggering an exploit to delete all of a user's files but not root's is still going to be plenty devastating.

Ideally the system should start the FUSE filesystem implementation under a system user account (maybe even DynamicUser=yes) to at least have some isolation for when the impl. is buggy.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 18:39 UTC (Wed) by mcatanzaro (subscriber, #93033) [Link]

Hm, this looks suspiciously close to an actual plan to improve the sorry situation. I wonder if this could work.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 20:41 UTC (Tue) by ebiederm (subscriber, #35028) [Link] (28 responses)

I tried having a session on this topic at Plumbers in 2018 in Vancouver.

Unfortunately the right people did not show up to move this issue forward.

As far as "safe" we have something like 3 filesystems believed to be safe: ramfs, tmpfs, and fuse. They are marked that way in the kernel.

Beyond that there are not any filesystems Itthat are safe to pick up in a parking lot, and plug into your computer. Ext4 is the closest. But no one supports safe operation against deliberately malformed filesystem images.

If you limit yourself to ext4, fat, and isofs you have a reasonable chance to not be immediately pwned.

There is a filesystem fuzzer that keeps running and reports how things break with deliberate filesystem corruption and it is burning out filesystem developers.

The very practical question is how do we get userspace to stop automounting filesystems, by default?

The automounting of filesystems by userspace by default has never made sense as it has never been supported by the kernel.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 21:28 UTC (Tue) by pizza (subscriber, #46) [Link] (18 responses)

> The automounting of filesystems by userspace by default has never made sense as it has never been supported by the kernel.

It is a very reasonable user expectation, going back all the way to the dawn of removeable storage.

It's not "automounting" that is the problem, it's the fact that "of course I want to access this drive, it's why I plugged it in!" is the overwhelmingly common use case. Even if the filesystems on the drive are not automounted, the user can be expected to immediately mount it (by double-clicking on an icon or whatever) and we're right back at square one.

Please keep in mind that overwhelmingly common attack vector for these files isn't "maliciously malformed filesystem", it's "malicious files on a well-formed filesystem".

Trust in and maintenance of filesystems

Posted Nov 21, 2023 21:47 UTC (Tue) by ebiederm (subscriber, #35028) [Link] (3 responses)

> It is a very reasonable user expectation, going back all the way to the dawn of removeable storage.

Which is why the question I was trying to get answered at the time is how do we do this safely.

The only answers I have found are fuse, and doing everything except the block device in user space.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 16:19 UTC (Wed) by DemiMarie (subscriber, #164188) [Link] (2 responses)

Or in a guest virtual machine.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 19:59 UTC (Wed) by pizza (subscriber, #46) [Link]

> Or in a guest virtual machine.

This would effectively collapse the "malicious filesystem" attack vector into the "malicious file on a well-formed filesystem" attack vector.

Sure, it's an improvement, but it does feel like a major case of premature optimization, focusing on a 2% problem while ignoring the far-more-common 98%.

(Meanwhile, how exactly are you supposed to designate a filesystem as "trusted" and what's to prevent an attacker from going after that designation, or subverting a supposedly-trusted filesystem? Or are you advocating for forcing everyone to take a *massive* performance haircut by sandboxing _everything_?)

Trust in and maintenance of filesystems

Posted Nov 22, 2023 21:08 UTC (Wed) by clump (subscriber, #27801) [Link]

A VM isn't a bad idea however it greatly increases the surface area for problems. libguestfs is a great tool however I've had guest mounts fail and I have no idea why.

Mounts handled by VM's could be a good thing, however you then start down the path of putting everything risky in VM's or containers. This approach has its own challenges.

Trust in and maintenance of filesystems

Posted Nov 24, 2023 9:54 UTC (Fri) by geert (subscriber, #98403) [Link] (13 responses)

Still, the GUI could offer some options or show some warnings, instead of blindly automounting anything. E.g.
- This is the first time you are mounting a <foo>fs? Do you want to mount it?
- For reading (and offer a "remount rw" option in the file manager),
- For reading and writing,
- Never auto-mount this type of file system,
[ ] Remember this choice.
- The device you just inserted is a multi-function USB device, and the storage part may be malicious. Are you sure you want to mount it?

Trust in and maintenance of filesystems

Posted Nov 24, 2023 10:16 UTC (Fri) by mjg59 (subscriber, #23239) [Link] (1 responses)

How do you expect an average user to have any insight into which filesystem types are trustworthy?

Trust in and maintenance of filesystems

Posted Nov 24, 2023 11:19 UTC (Fri) by Wol (subscriber, #4433) [Link]

> How do you expect an average user to have any insight into which filesystem types are trustworthy?

You're expecting too little from your average luser - a big security mistake.

Okay, well-trained lusers are hard to find, but if you can drum it in to them "if it looks odd, step back and think", you've won the battle. The "I'll click on anything" lusers are a lost cause whatever you do.

One of my lusers was proud of me training her that way - "if something goes wrong, step away from that keyboard and mouse!". Didn't stop her regularly pestering me for help. But it massively increased my chances of being able to solve her problem.

If we can train lusers to think "that looks suspicious", we've won.

Cheers,
Wol

Trust in and maintenance of filesystems

Posted Nov 24, 2023 11:16 UTC (Fri) by farnz (subscriber, #17727) [Link] (10 responses)

That last one is impossible to do perfectly - some multifunction USB devices appear as another vendor's mass storage (VID:PID copied from something the device manufacturer had lying around, I suspect), and reappear as their "real" function only when you send an "eject" SCSI command to them. But the real vendor's mass storage falls off the USB bus completely until replugged when you send it an "eject" command, which means that you can't send the eject command blindly; you first have to mount the device, see that the filesystem contents are that of the fake mass storage, and then unmount and eject.

But given that the goal is to avoid mounting filesystems blindly, this is problematic. On top of that, how do you phrase "<foo>fs" so that it's human-friendly? As a nerd, I can handle "fat32", "exfat", "ntfs", "xfs", "hfsplus" etc in that position, but how do you expect an average computer user to know that "exfat", "hfsplus" and "udffs" are expected, but "sysv" is not?

Trust in and maintenance of filesystems

Posted Nov 24, 2023 11:27 UTC (Fri) by Wol (subscriber, #4433) [Link] (1 responses)

Preface the file system type with "modern" or "legacy"?

Not that that'll help a lot. We need to give the luser as much *relevant* information as possible (without overloading them) and hope that it either reassures them or raises a red flag. Which is highly context dependent so we can't make that decision for them.

Cheers,
Wol

Trust in and maintenance of filesystems

Posted Nov 24, 2023 11:33 UTC (Fri) by farnz (subscriber, #17727) [Link]

Neither of those are particularly helpful in deciding if I should or should not mount this device; if I believe it came from an industrial control system running Windows 2000, should I mount it if it claims to be "legacy"? After all, Win2k is legacy by now, even though the likely FS on there is FAT32 or NTFS, which ought to be in the "modern" category.

The only thing that works is to disable mounting from the GUI of filesystems that are deemed "too insecure". Then, as an advanced user, I can open a terminal and mount using sysv, adfs, or other unusual FS. But this now opens up a new problem - which filesystems are "secure enough" to automount?

Trust in and maintenance of filesystems

Posted Nov 24, 2023 16:50 UTC (Fri) by geert (subscriber, #98403) [Link] (7 responses)

You replace "<foo>fs" by more explanation.
E.g. for hfsplus, you mention that it's typically used on Apple Macintosh systems; most people will understand that.
E.g. for sysv, you mention that it's typically used on System V/Xenix/V7/Coherent systems, and that, unless you know what that means, you do not want to proceed.
I guess the GUI usability people can come up with some sane wording ;-)

Trust in and maintenance of filesystems

Posted Nov 24, 2023 17:19 UTC (Fri) by pizza (subscriber, #46) [Link] (6 responses)

But no matter what sort of explanation about the seen-it-before/age/type/quality/color/whatever is used, the overwhemingly common case is "Of course I want to access the device, that's why I plugged it in", turning the prompt/whatever into a completely subconscious, automatic "<click on OK>".

Hate to say it, but the only path forward here seems to be to sandbox everything removeable (which in practice means everything other than stuff that shares the same physical drive as the rootfs) while (forever?) continiung to plug the bugs/holes in the implementations.

Trust in and maintenance of filesystems

Posted Nov 24, 2023 18:10 UTC (Fri) by Wol (subscriber, #4433) [Link] (5 responses)

> But no matter what sort of explanation about the seen-it-before/age/type/quality/color/whatever is used, the overwhemingly common case is "Of course I want to access the device, that's why I plugged it in", turning the prompt/whatever into a completely subconscious, automatic "<click on OK>".

As I said, you can't fix the "click on anything" luser.

But if the user has plugged in a MOUSE, a "do you want to mount it?" prompt *should* raise eyebrows. If the user has found a USB stick in the car park, any information we can give them is a plus - provided they have minimal common sense (I know I know). Why abandon the lusers with a few working brain cells, all to avoid upsetting the lusers who have none?

Cheers,
Wol

Trust in and maintenance of filesystems

Posted Nov 24, 2023 18:22 UTC (Fri) by farnz (subscriber, #17727) [Link] (2 responses)

First, note that you do get a "do you want to mount this" prompt for each USB device that's plugged in - we only have to consider the case where the user is expecting to mount a USB device, but an attacker has set this up to break their security barriers (e.g. dropped off a USB stick in the car park with a malicious sysv filesystem on it).

Second, there's a better policy than "hey, I could mount this" for all filesystems; allowlist a set of plausible external media filesystems, and only offer to mount devices that contain one of those filesystems. Make it hard to mount other filesystems (e.g. CLI tool, or option hidden in a menu instead of in the file manager sidebar); don't notify for filesystems that are suspicious.

The only issue with this policy today is that there are filesystems (such as NTFS) that are plausible external media filesystems, but that aren't safe to mount if an attacker has had the chance to craft a malicious filesystem image.

Trust in and maintenance of filesystems

Posted Nov 24, 2023 19:23 UTC (Fri) by pizza (subscriber, #46) [Link] (1 responses)

> (e.g. dropped off a USB stick in the car park with a malicious sysv filesystem on it).

...In other words, an attacker is after *you* specifically, already knows quite a lot about you and your environment, and has the resources and time to plan a stealthy attack.

...In other words, you're already completely boned; you just don't know it yet.

Trust in and maintenance of filesystems

Posted Nov 24, 2023 22:57 UTC (Fri) by farnz (subscriber, #17727) [Link]

That's true for any attack on Linux users based on malicious filesystems right now; we're rare enough that you'd have to target us specifically, and not use a generic attack.

And just because I found a USB stick in a car park doesn't mean it's targeting me - I could, for example, have picked it up in the grocery store parking lot, and it could have been targeted at the grocery store employees, not me. So the attacker knows very little about me and my environment, I'm just caught out because the grocery store environment is close enough to mine to be attacked.

Trust in and maintenance of filesystems

Posted Nov 24, 2023 18:23 UTC (Fri) by pizza (subscriber, #46) [Link] (1 responses)

> But if the user has plugged in a MOUSE, a "do you want to mount it?" prompt *should* raise eyebrows.

And I'm saying that no, it won't.

> Why abandon the lusers with a few working brain cells, all to avoid upsetting the lusers who have none?

Because, even amongst infosec-aware folks, the _overwhelming overwhelming_ common use case will lure that prompt into an automatic, subconcious, "OK".

It will barely budge the needle in the best case, and in the normal case, it'll just annoy users, if not become actually counterproductive.

(Witness the Windows UAC escalation prompt, in case there's any doubt in what I'm saying)

Trust in and maintenance of filesystems

Posted Nov 24, 2023 20:29 UTC (Fri) by johill (subscriber, #25196) [Link]

> > But if the user has plugged in a MOUSE, a "do you want to mount it?" prompt *should* raise eyebrows.
> And I'm saying that no, it won't.

It's pretty common for random devices to come with mass-storage of some sort integrated, for drivers or documentation. Some devices even require you to eject the "CD-ROM drive" before you can use them normally.

So ... yeah, it won't?

Trust in and maintenance of filesystems

Posted Nov 21, 2023 22:32 UTC (Tue) by bartoc (guest, #124262) [Link] (1 responses)

my impression is that modern GNOME doesn't automount (you need to actually click the filesystem to get it to mount), and it strongly prefers to use fuse implementations for removable media even then. I think it might automount and use kernel filesystems for less removable media like SATA or SAS disks, NVME, etc.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 14:18 UTC (Wed) by cesarb (subscriber, #6266) [Link]

> my impression is that modern GNOME doesn't automount (you need to actually click the filesystem to get it to mount)

In my experience, it does automount hotplugged USB storage devices, going as far as asking for the LUKS password when the device is encrypted. I don't know if it has a whitelist, but at least VFAT, ext4, XFS, btrfs, and the CD/DVD filesystems (iso9660 and UDF) seem to be automounted.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 14:08 UTC (Wed) by epa (subscriber, #39769) [Link]

Safe operation against deliberately malformed filesystem images is currently not possible. But what about safe *read-only* operation? Do we perhaps have a chance at achieving that in a few limited cases?

Trust in and maintenance of filesystems

Posted Nov 22, 2023 19:03 UTC (Wed) by mcatanzaro (subscriber, #93033) [Link] (5 responses)

Honestly I think you're approaching this problem with an unrealistic security model in mind. I will try to more precisely restate what others here have already mentioned. First, let's agree that the security risk of automounting a filesystem ***relative to manually mounting that same filesystem*** is zero. That is, if the user is going to manually mount the filesystem anyway, then automounting it doesn't make any security difference. Then the only remaining question is how likely are users to manually mount a filesystem that the desktop decided to not automount? This is up for debate, but I propose that users are *overwhelmingly* likely to want to manually mount the filesystem. It's not like users plug in USB devices or other storage media with the intent of not using them. So the desktop might as well go ahead and mount, because otherwise the user will imminently do so anyway. Automounting is convenient and will not make the user any less safe in practice.

I view the discussion of whether or not to automount as a distraction from the real problem, which is how to make mounting filesystems safer. Fuzzing filesystems is surely part of the answer. Reducing the set of filesystems supported by the kernel, or perhaps making it harder to enable niche filesystems, would probably also be good to do. I also see an alternative proposal here that userspace should be using FUSE. I'm not familiar with FUSE and don't know if it's a good idea or not, but if nothing else at least that's attacking the underlying problem.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 20:56 UTC (Wed) by rra (subscriber, #99804) [Link] (1 responses)

One of the security threat models here does involve plugging in USB storage devices without intending to use them: they thought they were plugging in some other USB device that uses a file system as a malicious payload.

It used to be that there were enough low-level attacks on the USB subsystem from a generic USB device being attached that one didn't need to bother to go all the way to a malicious file system, but I think a lot of them may have been cleaned up? It's possible that an automounted malicious file system hiding in a USB mouse or the like could now be the lower-effort attack.

Trust in and maintenance of filesystems

Posted Nov 25, 2023 15:04 UTC (Sat) by mcatanzaro (subscriber, #93033) [Link]

Actually I don't think generic attacks have been cleaned up. An easy example that we are still vulnerable to is the USB rubber ducky, which is a keyboard device that looks like a USB stick and can be programmed to submit malicious key presses. These are cheap and very easy to buy and deploy.

The defense against such a device would be to present the user a dialog showing one picture of a USB storage device and one picture of a keyboard, and ask the user what device was plugged in? The user will click on the USB storage device, and then the desktop knows the user has plugged in a malicious device, without the user having to make any security decision. But we've never implemented this.

That's a completely different problem to the malicious filesystem on a USB device, of course. A malicious filesystem is harder to defend against.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 23:46 UTC (Wed) by cesarb (subscriber, #6266) [Link] (2 responses)

> First, let's agree that the security risk of automounting a filesystem ***relative to manually mounting that same filesystem*** is zero. That is, if the user is going to manually mount the filesystem anyway, then automounting it doesn't make any security difference.

There are at least two situations in which the user is not going to manually mount the filesystem anyway:

1. The user is not even there. That is, if the screen is locked, it should never automount.

2. The user did not think the device had a filesystem. For instance, the user thought the device was a keyboard or a mouse.

As a borderline variant of this second situation, the device has multiple uses, and the user plugged the device to do something else. I often plug my smartphone into my computer to charge it, not to copy files from or to it (though I also do that occasionally).

Trust in and maintenance of filesystems

Posted Nov 23, 2023 1:35 UTC (Thu) by pizza (subscriber, #46) [Link]

> As a borderline variant of this second situation, the device has multiple uses,

I own two such devices; one is a cellular modem and the other is a label printer. Both provide a mass-storage function containing a filesystem that contains the drivers/utilities necessary for $other_os to utilize the hardware. I also own a pile of various microcontroller development boards that present entirely fake filesystems in order to facilitate easy, tool-less firmware updates.

This approach is not new, and none of these device classes are terribly unusual. (Incidently, earlier versions of the fake filesysstem on one of those microcontroller boards triggered pathological behavior and outright panics in the Linux USB stack, mass storage drivers, and even the FAT filesystem code!)

But by all means, prevent auto-mounting when the user isn't physically present -- But what happens when the user returns? Something I tend to do is plug a device into my system before I unlock it. If someone else plugged in something as well, how do I identify which is the one I want, especially when it's quite common to have multiple mass storage devices plugged in at once?

...And even if your device/filesystem is legitimate (ie well-formed) the files it contains more than likely are not trustable. If the last decade of corporate security training has taught me anything, that's the threat vector they're most concerned about -- any anything truly sensitive has network access and/or USB ports completely disabled.

Trust in and maintenance of filesystems

Posted Nov 25, 2023 15:09 UTC (Sat) by mcatanzaro (subscriber, #93033) [Link]

1. Agreed, although the device will also be blocked by usbguard, which GNOME has supported for a while now. Distros should probably turn this on.

2. Agreed, although I'm not sure why an attacker would go to the effort of making a keyboard present itself as a USB storage device. Maybe if you're trying to attack a secure facility where the employees know not to plug in USB storage devices but are allowed to use their own keyboards.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 21:25 UTC (Tue) by ju3Ceemi (subscriber, #102464) [Link] (20 responses)

The kernel devs answered your question : no filesystem code is safe against a crafted filesystem

Hence : "This automounting exposes the system to security threats and is always a bad idea"

You (the people who did automount) are doing something insecure by design
Live with it and stop doing it

Trust in and maintenance of filesystems

Posted Nov 21, 2023 23:29 UTC (Tue) by ebassi (subscriber, #54855) [Link] (19 responses)

Ask yourself this: what difference does it make if the device with the file system gets mounted automatically, or the user mounts it themselves as soon as it's available?

If the answer is: "we get to blame the user, now", then please stop writing software or administering systems, and go do something else with your time.

Otherwise, you need to figure out what to do when that happens.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 3:09 UTC (Wed) by NYKevin (subscriber, #129325) [Link] (5 responses)

> If the answer is: "we get to blame the user, now", then please stop writing software or administering systems, and go do something else with your time.

Workstations are hardly the primary use case of the kernel. Most Linux devices are Android; if you exclude them, most are probably in a server rack somewhere. Nobody should be plugging random drives into a server, and I think it is rare in practice to plug things into Androids too.

In other words: For the vast majority of real actual Linux systems, automounting or even manual mounting is completely unnecessary (other than at boot time).

I realize this is a somewhat unhelpful response, for the GNOME people, but nobody ever said that supporting GNOME is or should be the kernel's top priority.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 9:41 UTC (Wed) by tux3 (subscriber, #101245) [Link]

I'm not sure I understand. Is the argument that we should not solve problems for workstation and laptop users of Linux, because there are many more people who have phones?
This is a philosophy that works best if one is always part of the majority group, but I don't see that the kernel can't try to solve multiple problems at the same time and try to serve different types of users.

Regardless, unmaintened filesystems don't cause trouble only for lap & desk top users. Even from a purely inward-looking angle, I'm fairly sure server admins shouldn't see a reason to complain if filesystems they don't use are more clearly marked deprecated (or removed in an orderly manner), simplifying maintenance of the kernel they use.

Arguing that people shouldn't solve problems you don't have is already a dubiously noble endeavor, but especially when everyone would benefit from a clean solution. The maintenance cost of entire filesystems that no one understands is not negligible.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 9:50 UTC (Wed) by DemiMarie (subscriber, #164188) [Link]

Android mounts untrusted f2fs filesystems on literally every boot. If one can compromise Linux via a malicious f2fs filesystem, then one can bypass Android Verified Boot and persist a kernel compromise even after the initial bug that allowed it was patched.

ChromeOS does the same thing with untrusted ext4 images and ChromeOS’s verified boot feature.

If someone is aware of a security vulnerability in ext4 or f2fs that is not obviously limited to denial of service, that should be reported to the ChromeOS or Android security teams, respectively. This includes problems found by fuzzers.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 20:36 UTC (Wed) by khim (subscriber, #9252) [Link] (2 responses)

> Most Linux devices are Android

Which, of course, automatically mount filesystems from USB sticks, too.

Apple tried to resist for a long time (not because of security, but because they wanted to sell larger-storage models for extra $$), but today iPad does that, too.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 20:38 UTC (Wed) by ju3Ceemi (subscriber, #102464) [Link] (1 responses)

Are those mounted in kernel space ?

Trust in and maintenance of filesystems

Posted Nov 22, 2023 20:42 UTC (Wed) by khim (subscriber, #9252) [Link]

Most of the time, yes. Remember that story when Samsung was pushed to publish sources for it's exFAT driver. Why do you think it even developed that driver in the first place, hmm?

Trust in and maintenance of filesystems

Posted Nov 22, 2023 9:18 UTC (Wed) by ju3Ceemi (subscriber, #102464) [Link]

You know, anybody can quite easily plug an USB stick in the back of my workstation, at work, I would not notice
So when you say "the user", you mean "one human which is not necessarily the user but could be a malicious actor"

But in fact, none of this matter.
You have the current situation now : mounting untrusted filesystem is a security issue.
Now, you must move based on that.

You took the decision the carry that burden and push your users at risk without them even knowing something is happening.
That is your call.

I am a user too, and I do not automount stuff. When I plug a stick, I click "mount" and the stuff is mounted. And if I have no idea what the device that just spawned is, then I do not mount it.

Indeed, fixing all the code in the world to make is secure would be nice. In the meantime, here we are.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 10:07 UTC (Wed) by DemiMarie (subscriber, #164188) [Link]

The filesystem should be mounted via FUSE in a tightly sandboxed environment, such as a KVM VM. The sandbox then becomes the security boundary: an attacker can compromise the sandbox, but cannot then compromise the rest of the system.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 11:30 UTC (Wed) by MarcB (subscriber, #101804) [Link] (1 responses)

> Ask yourself this: what difference does it make if the device with the file system gets mounted automatically, or the user mounts it themselves as soon as it's available?

This turns the attack from "simply plug this key into an unattended laptop" into "trick the laptop's owner into mounting it". This likely is much harder.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 13:47 UTC (Wed) by pizza (subscriber, #46) [Link]

> This turns the attack from "simply plug this key into an unattended laptop" into "trick the laptop's owner into mounting it". This likely is much harder.

Then it's a good thing that the former doesn't automatically mount, eh?

(I just verified this behaviour by plugging a storage device into my locked F39 laptop running GNOME 45 -- the kernel dmesg shows the device was detected, but nothing was mounted until I unlocked the screen then clicked on it)

Trust in and maintenance of filesystems

Posted Nov 23, 2023 4:40 UTC (Thu) by magnus (subscriber, #34778) [Link] (8 responses)

On the desktop there could be a warning when first mounting an external (usb) drive that has not been seen before based on vendor and maybe some basic information that could be safely extracted from the drive without mounting it. And then maybe a "safe mode" allowing basic file browsing without mounting as if it was a zip file or such, possibly with the parsing isolated into a separate process.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 7:54 UTC (Thu) by mjg59 (subscriber, #23239) [Link] (7 responses)

If it's acceptable to mount the filesystem in some external process then why not just do that all the time? USB devices don't cryptographically verify their identity, so you can't simply trust data that the device is giving you in order to determine whether or not the data on it is trustworthy.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 9:07 UTC (Thu) by magnus (subscriber, #34778) [Link] (6 responses)

What i meant (maybe unclearly) was that you could have a user space process that understands the file system layout and just accesses the raw drive directly with read/write/seek and acts as a kind of ftp server for the drive, and in worst case crashes on a corrupted fs without taking the system with it. That would be for cases where you just want to browse contents of an untrusted usb drive and copy the odd file or so but wouldnt be a substitute for a proper mount..

Trust in and maintenance of filesystems

Posted Nov 23, 2023 10:07 UTC (Thu) by mjg59 (subscriber, #23239) [Link] (5 responses)

Isn't this just FUSE?

Trust in and maintenance of filesystems

Posted Nov 23, 2023 11:00 UTC (Thu) by farnz (subscriber, #17727) [Link] (4 responses)

I read the comment as closer to GVfs in intent than to FUSE; a library that lets you read and write the FS using special case operations so that you know you're not on a trusted FS, but on a possibly untrusted device.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 11:09 UTC (Thu) by mjg59 (subscriber, #23239) [Link] (3 responses)

I don't really see a beneficial difference there? You're going to go through the same amount of parsing code and it's going to be subject to the same set of vulnerabilities, so having that be out of process rather than in process seems like it's easier to impose constraints on it

Trust in and maintenance of filesystems

Posted Nov 23, 2023 11:22 UTC (Thu) by farnz (subscriber, #17727) [Link]

Both FUSE and GVfs put the FS parsing code in a separate process; the only significant difference is that the preferred way to access a FUSE protocol filesystem is to mount it like a "trusted" kernel filesystem, while GVfs is accessed via GIO calls that turn into DBus method calls. This means that if I have a GVfs style filesystem, it's harder to chain attacks into loading code from the filesystem than if I've got a FUSE filesystem (for example, if there's a bug in the program that I can exploit to make it pass an arbitrary path to dlopen or equivalent, I can't use it to dlopen something on a GVfs type filesystem, but I can in theory use it to dlopen something on a FUSE filesystem).

That said, GNOME promptly breaks the extra security benefits of GVfs by having a FUSE bridge that automounts the filesystems as FUSE filesystems, so it's a wash in practice.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 20:26 UTC (Thu) by magnus (subscriber, #34778) [Link] (1 responses)

I guess i was thinking about avoiding vulnerabilities in FUSE itself and also allowing a much smaller set of operations (basic file access but no mmaping etc) but maybe FUSE is simple enough to make the risk of using it low?

Trust in and maintenance of filesystems

Posted Nov 24, 2023 4:12 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link]

The kernel-side FUSE was from the start designed to be robust against malicious data. BTW, it does support mmap.

Userspace developers here!

Posted Nov 22, 2023 19:41 UTC (Wed) by mcatanzaro (subscriber, #93033) [Link]

> A few developers expressed frustration with a perceived inability to get a response from user-space developers on topics like this.

Hmm, it seems like we have some communication issues to resolve. Just getting in touch shouldn't be hard.

ebassi and myself both represent the GNOME security team, and we're both participating in the comments here on this LWN article, so you've at least got our attention if nothing else. We have left our thoughts regarding automounting in other comments on this article.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 17:18 UTC (Tue) by josh (subscriber, #17465) [Link]

> Hellwig concurred with the problem, saying that there is an implicit assumption in the community that this sort of API cleanup is a low-priority task; as a result it is easily blocked. There needs to be a way to force developers to move to newer APIs. Bergmann mentioned the desire to remove high memory, but 32-bit Arm still needs it, so it cannot be removed from anywhere, imposing significant costs on the kernel as a whole. Chinner complained that increasing amounts of work are being placed on maintainers to keep old code working; maintainers are at the limit of what they can do now, and this path is unsustainable, he said.

If it's permitted to mark things as deprecated, and produce warnings when building architectures/drivers that haven't been updated, that'd be a substantial improvement. Usually producing new warnings is not allowed; if it were allowed that'd help nudge architecture/driver maintainers in the right direction.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 19:14 UTC (Tue) by ballombe (subscriber, #9523) [Link] (1 responses)

I never had any sympathy with the 'no bug report -> no user' perspective.
This is the wrong logic to apply. Bugs are not a communication medium.
If you want to know about users of your code, reach out to them, do not expect them to report spurious bugs just so you know they exist. Even if you purposely break the code to see whether they complain, the broken version might take years to reach them.

Also sometime reporting a bug in a feature leads to the feature to be removed rather than fixed (e.g. console scrolling),
so the incentive to report a bug can be negative.

Trust in and maintenance of filesystems

Posted Nov 21, 2023 20:00 UTC (Tue) by pizza (subscriber, #46) [Link]

> I never had any sympathy with the 'no bug report -> no user' perspective.

Especially when the users expected to make the most use of these "obsolete" filesystems are most likely using Enterprise or LTS-type distributions, meaning that there could easily be literally years between a filesystem getting dropped upstream and the user discovering their old filesystems can't be read any more.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 0:54 UTC (Wed) by mb (subscriber, #50428) [Link] (4 responses)

Preventing automounting doesn't really solve any problem.
The user will mount a drive that the user has just plugged in. Why else would the user plug it in?

The only solution is to fix the safety bugs in the filesystems and to completely disable or drop filesystems that nobody wants to fix.
And the real problem here is social. Not technical.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 21:21 UTC (Wed) by hmh (subscriber, #3838) [Link]

It does. Requiring an user acknowledgement to mount avoids several issues such as passerby plugs device into a locked computer.

In fact, automounting is so bad an idea, it is *not* done by default anymore in any distro, as far as I know.

There is a report in this article comments already that fedora does not do this kind of foolhardy temerary automounting on gnome, and I know for a fact Debian doesn't do it in KDE (did not try gnome).

Trust in and maintenance of filesystems

Posted Nov 23, 2023 11:38 UTC (Thu) by dezgeg (guest, #92243) [Link] (2 responses)

Would the user still be willing to mount if they'd see beforehand that the filesystem type is sysv or something equally weird/obsolete?

Trust in and maintenance of filesystems

Posted Nov 23, 2023 15:50 UTC (Thu) by anselm (subscriber, #2796) [Link] (1 responses)

Would the user still be willing to mount if they'd see beforehand that the filesystem type is sysv or something equally weird/obsolete?

I'd say relying on random users being able to tell which file system implementations in the Linux kernel are weird, obsolete, etc. is probably a little naive. IMHO it's fairly safe to assume that people will just click on “OK” to get rid of the prompt.

Trust in and maintenance of filesystems

Posted Nov 24, 2023 10:44 UTC (Fri) by farnz (subscriber, #17727) [Link]

About the only way you can make that work, at all, is a whitelist, where you can click to mount "likely" filesystems (FAT32, exFAT, NTFS, xfs, ext4 etc), but need to do more work to mount an "unlikely" filesystem (sysv, minix etc) such as going into the filesystem reformatting tool and telling it you want to mount the filesystem.

Even then, this isn't perfect, since there is a route to getting you to mount the filesystem by clicking, and malware will come with instructions telling you to do just that.

Trust in and maintenance of filesystems

Posted Nov 22, 2023 4:49 UTC (Wed) by dxld (subscriber, #90530) [Link] (3 responses)

I wonder, has anyone considered it's not the automounting itself that's the problem, but automounting while the system's owner is not in front of the machine?

GrapheneOS has this setting to only allow USB devices to be enumerated when the screen isn't locked. Seems that's what we need on the Linux desktop too. I've implemented something like that for one of my embedded projects and it's actually pretty easy to implement: https://docs.kernel.org/usb/authorization.html

--Daniel

Trust in and maintenance of filesystems

Posted Nov 22, 2023 21:14 UTC (Wed) by hmh (subscriber, #3838) [Link] (1 responses)

You likely want to allow HID devices through, otherwise you can shoot yourself very hard on the foot way too easily, if you need said HID device to unlock and it goes through a disconnect event.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 8:20 UTC (Thu) by dxld (subscriber, #90530) [Link]

Hmm. True, phones don't have that problem. Me personally I'd be happy to trade of not being able to unplug/replug HID devices for additional rogue USB protection as you can always just hit that (ACPI) power button to reboot, but I don't see a fundamental reason it shouldn't be possible to still allow HID devices through while locked.

I might worry about the device switching role (HID->storage) while plugged, but IIRC only the host is allowed to change the selected USB device configuration but that'd be something to audit and test.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 12:59 UTC (Thu) by ebassi (subscriber, #54855) [Link]

> Seems that's what we need on the Linux desktop too.

GNOME already requires an unlocked session for mounting USB devices.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 6:32 UTC (Thu) by gdt (subscriber, #6284) [Link] (2 responses)

API-wise, user-space needs more information than just the estimate of robustness of the driver. Some filesystem information such as the label, size, creation date and other dates would assist users in deciding if the volume is to be mounted. That's going to require a specific function in every filesystem driver, so that those fields are retrieved from the superblock with the least possibility of bugs.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 7:52 UTC (Thu) by mjg59 (subscriber, #23239) [Link] (1 responses)

Why would any of that inform a user of whether they should mount the filesystem? Why would any hostile actor not simply set those values to something the user expects?

Trust in and maintenance of filesystems

Posted Nov 24, 2023 10:49 UTC (Fri) by gdt (subscriber, #6284) [Link]

If hostile actors are a threat, then no USB storage which has ever passed out of the control and knowledge of the user should be connected to the system, let alone be considered for mounting. The user should regard the contents as irretrievable and shred the storage so the contents can't be retrieved by parties with more appetite for risk.

Outside the infosec bubble, risks are gauged with more nuance. Information about the filesystem can prompt the user's memory if they have retained some form of control over the USB storage, even if that's a decade in a drawer.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 9:03 UTC (Thu) by taladar (subscriber, #68407) [Link]

> Hellwig said that there would need to be at least three levels: "no trust", "generally maintained but don't mount untrusted images", and "well maintained".

If the kernel does add some sort of filesystem trust level the "actively developed but not yet ready for production use" use cases should also be considered since it is not just deprecated and unmaintained code that should not be used automatically.

Trust in and maintenance of filesystems

Posted Nov 23, 2023 14:38 UTC (Thu) by jd (guest, #26381) [Link]

Obviously Reiserfs and Reiser4 are problematic, but what other filesystems are being eyeballed as potentially unused?

It's worth considering that a lot of the filesystems on Linux have a range of use cases where they're optimal, but that many Linux distros default to single partitions rather than a mix-match approach with several partitions, and offer a very limited subset of filesystems even with manual partitioning.

The practical upshot is that filesystems that are actually very useful and would improve a user's experience will be underutilised due to the added difficulty.

I can understand why distros do this (it's easier to write and test the installer, behaviour is more predictable, and users have less to track), but if it's leading to user experiences being impacted and genuinely useful features withering on the vine, maybe that needs rethinking.

The effort involved in installing new filesystems tools, reformatting partitions, and setting them back up is going to deter most people.

It just bothers me that filesystems that might actually be really valuable might end up being chopped, where ultimately it's because to keep the installer simpler/smaller.

Trust in and maintenance of filesystems

Posted Nov 25, 2023 18:36 UTC (Sat) by raven667 (guest, #5198) [Link]

What about waiting for an explicit action from the user accessing the filesystem to mount it, either clicking on it in the GUI or cd into the directory from cli with limits for automation like indexing utilities that might accidentally activate the mount. That should reduce a number of casual attack vectors where stuff happens in an unattended way, in addition to not mounting when locked and using sandboxed FUSE for removable media.

Mechanisms dont have to be perfect to be useful

Trust in and maintenance of filesystems

Posted Dec 1, 2023 17:22 UTC (Fri) by mrshiny (guest, #4266) [Link]

I don't understand the mentality of "don't check for security bugs in unmaintained code". If the code can't be removed, then those security bugs are still security bugs regardless of whether or not someone wants to fix them.


Copyright © 2023, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds