Bug 272446 - automount -c clobbers flags of mounted direct map entries
Summary: automount -c clobbers flags of mounted direct map entries
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Konstantin Belousov
URL: https://reviews.freebsd.org/D40961
Keywords:
Depends on:
Blocks:
 
Reported: 2023-07-10 17:52 UTC by Andrew "RhodiumToad" Gierth
Modified: 2023-12-27 12:41 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew "RhodiumToad" Gierth 2023-07-10 17:52:04 UTC
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
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-10-17 16:42:33 UTC
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(+)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-10-17 16:42:34 UTC
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(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-10-24 00:46:57 UTC
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(+)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-10-24 00:47:00 UTC
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(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-10-24 00:48:01 UTC
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(+)
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-10-24 00:48:03 UTC
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(-)
Comment 7 Mark Linimon freebsd_committer freebsd_triage 2023-12-27 12:41:25 UTC
^Triage: assign to committer who resolved and MFCed.