#1114516 mount: umount unexpectedly ignores -t (--types) argument if -a (--all) is not specified

Package:
mount
Source:
mount
Description:
tools for mounting and manipulating filesystems
Submitter:
Jurij Smakov
Date:
2025-09-06 11:55:02 UTC
Severity:
normal
Tags:
#1114516#5
Date:
2025-09-06 10:31:37 UTC
From:
To:
Hi,

I ran into this when configuring autofs direct mounts, which creates a trigger
mount and the actual mount at the same mount point (whenever the auto-mounting
triggers), so mounts may look like these, for example:

$ mount | grep /mnt/tmp
/etc/auto.direct on /mnt/tmp type autofs (rw,relatime,fd=9,pgrp=1582,timeout=300,minproto=5,maxproto=5,direct,pipe_ino=21088)
tmpfs on /mnt/tmp type tmpfs (rw,relatime,inode64)

First entry is the autofs trigger mount, with type autofs. The second one is the
actual mount, triggered by changing the directory to /mnt/tmp.

One may want to try and unmount the actual (tmpfs) mount using a command like
this one, leaving the autofs trigger mount in place:

sudo umount -t tmpfs /mnt/tmp

However, if tmpfs is not currently mounted, then this command will also remove
the autofs trigger mount, despite its type being autofs. This is unexpected
behavior, which can also be disruptive, since removing the trigger mount will
prevent future auto-mounting of /mnt/tmp from functioning properly, until the
next reload of the autofs service.

The potential fix appears to be a simple one, setting up of the types filter
just needs to be moved out of the clause which is only triggered for --all:
https://github.com/util-linux/util-linux/blob/master/sys-utils/umount.c#L624

This bug affects the trixie version of umount as well.