Skip to contentSkip to conversation

Improper Link Resolution Before File Access ('Link Following') and Time-of-check Time-of-use (TOCTOU) Race Condition in libfuse (GHSA-926f-3q38-ff52)

libfuse/libfuse Darrick J. Wong 1 participant 1 message Jun 9 4 messages not in the archive FUSE filesystem core

lore
Share & tools
lore
#4 lore raw
In reply to a message not in the archive

[add fuse-devel to cc]

TLDR: Bernd got a complaint through github about how you can trick fuservicemount into unmounting the wrong path by racing a fuse service asking for an unmount against someone creating symlinks to critical mounts. The reporter suggested using UMOUNT_NOFOLLOW, but...

Quoted 14 lines · Bernd Schubert
Quoted 11 lines · Darrick J. Wong
Quoted 3 lines · Bernd Schubert

Hi Darrick,

could you take care of this?

How do you want to take care of it? In-kernel filesystems do not unmount themselves, so this particular libfuse feature is novel to me. I don't really get why libfuse has the autounmount feature; if a filesystem fails to mount, surely you'd rather it just stay there so the application errors are obvious.

Quoted 7 lines
Quoted 1 line

<shrug>

That predates me and I was already complaining at LPC 2024 in our fuse session.

Maybe we can disable auto umount for fuse service mount? I didn't have time to check at all.

There's no auto unmount. The fuse service itself has to request the unmount. But since that's unreleased code, let's just rip it out.

Quoted 3 lines

On my urgent todo list is to switch auto mount with the new mount api to mount fd and maybe disable auto umount without new mount api by default (as compile time option)

Yeah, I think we should just kill it because there's (AFAICT) no good usecase. If the fuse server fails, we want the dead mount to stick around so that file IO fails instead of silently(?) going to the parent filesystem. I guess the problem is that there's probably some weird old usecase out there, like auto-unmounting /home/XXX from NFS when you log out of a server and not having the unmount get stuck due to dead fusermount mounts.

Quoted 6 lines
Quoted 4 lines

Since the mount service API is new and nobody uses it (not even fuse4fs) we could just remove it. Assuming you haven't cut a release, we could probably get away with removing the ABI entirely. If not, we could just make it reply with EINVAL/EOPNOTSUPP unconditionally.

I'm all for it :)

Removing it? OK. :)

Quoted 5 lines
Quoted 2 lines

That said, why is it the case that most of the other umount2 calls in libfuse *don't* pass UMOUNT_NOFOLLOW?

No idea, as per above, it predates me ;) I guess we won't need that anymore with umount by mount fd?

I don't think the new fsmount APIs actually cover *unmounting*. Once the mount is exposed to the directory tree, anyone else can walk in and start bind mounting it all over the place.

--D

Quoted 5 lines

Thanks for looking at that!

Bernd