If you try and enable both the -media and -noauto maps from the sample auto_master, and enable use of automount -c from devd as suggested in the comments, then on every devd event, the flags of all the -noauto filesystems are reset (clearing the "automounted" flag and, more critically, flags such as "readonly" and "nosuid"). This happens because when traversing the mount list, there are two entries for each -noauto map entry that is currently active: the autofs filesystem itself, and the real filesystem mounted on top of it. The automount program sees the first of those, and issues the equivalent of "mount -u /path" on it, WITHOUT checking whether "/path" is currently mounted over. This can be partially fixed in the userland code, but that obviously leaves a race condition. Accordingly the attached review includes both a kernel and a userland change: the kernel change is to require that the fstype field passed to nmount does actually match the VFS type of the filesystem to be updated. https://reviews.freebsd.org/D40961
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=21b8e363c4eb24c0a5659101603cc08a86d87759 commit 21b8e363c4eb24c0a5659101603cc08a86d87759 Author: Andrew Gierth <andrew@tao146.riddles.org.uk> AuthorDate: 2023-07-10 15:09:56 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-17 16:40:45 +0000 automount: check for mounted-over autofs instances on flush PR: 272446 Reviewed by: kib MFC after: 1 week Differential revision: https://reviews.freebsd.org/D40961 usr.sbin/autofs/automount.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=56c44bd92efa002b2185445878fc98172ae8c66f commit 56c44bd92efa002b2185445878fc98172ae8c66f Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-09-29 18:43:42 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-17 16:40:50 +0000 automount(8): when flushing autofs, specify fsid Which should avoid situation where flushed filesystem is not autofs, because it was mounted over autofs mp. Reported and tested by: Andrew "RhodiumToad" Gierth <andrew@tao11.riddles.org.uk> PR: 272446 Reviewed by: mjg Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D42023 usr.sbin/autofs/automount.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=361f7820cde9cc9e9eb7118155b6a39c1a52ef9d commit 361f7820cde9cc9e9eb7118155b6a39c1a52ef9d Author: Andrew Gierth <andrew@tao146.riddles.org.uk> AuthorDate: 2023-07-10 15:09:56 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-24 00:46:01 +0000 automount: check for mounted-over autofs instances on flush PR: 272446 (cherry picked from commit 21b8e363c4eb24c0a5659101603cc08a86d87759) usr.sbin/autofs/automount.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
A commit in branch stable/14 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c5f92e2ac8aad3c0d5e9659257f02846944bb347 commit c5f92e2ac8aad3c0d5e9659257f02846944bb347 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-09-29 18:43:42 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-24 00:46:02 +0000 automount(8): when flushing autofs, specify fsid PR: 272446 (cherry picked from commit 56c44bd92efa002b2185445878fc98172ae8c66f) usr.sbin/autofs/automount.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=29dae977ae9b01f429ae876743514da92ee8ecf4 commit 29dae977ae9b01f429ae876743514da92ee8ecf4 Author: Andrew Gierth <andrew@tao146.riddles.org.uk> AuthorDate: 2023-07-10 15:09:56 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-24 00:47:20 +0000 automount: check for mounted-over autofs instances on flush PR: 272446 (cherry picked from commit 21b8e363c4eb24c0a5659101603cc08a86d87759) usr.sbin/autofs/automount.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=2746fc0a5c8956deb2a13822c640fbee0fba5b95 commit 2746fc0a5c8956deb2a13822c640fbee0fba5b95 Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2023-09-29 18:43:42 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2023-10-24 00:47:20 +0000 automount(8): when flushing autofs, specify fsid PR: 272446 (cherry picked from commit 56c44bd92efa002b2185445878fc98172ae8c66f) usr.sbin/autofs/automount.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
^Triage: assign to committer who resolved and MFCed.