Date: Tue, 24 Oct 2023 00:47:49 GMT From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 29dae977ae9b - stable/13 - automount: check for mounted-over autofs instances on flush Message-ID: <202310240047.39O0lnZI005073@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib: 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(+) diff --git a/usr.sbin/autofs/automount.c b/usr.sbin/autofs/automount.c index 188bbc3a040f..cee647cb4e2c 100644 --- a/usr.sbin/autofs/automount.c +++ b/usr.sbin/autofs/automount.c @@ -260,6 +260,7 @@ static void flush_caches(void) { struct statfs *mntbuf; + struct statfs statbuf; int i, nitems; nitems = getmntinfo(&mntbuf, MNT_WAIT); @@ -274,6 +275,21 @@ flush_caches(void) mntbuf[i].f_mntonname); continue; } + /* + * A direct map mountpoint may have been mounted over, in + * which case we can't MNT_UPDATE it. There's an obvious race + * condition remaining here, but that has to be fixed in the + * kernel. + */ + if (statfs(mntbuf[i].f_mntonname, &statbuf) != 0) { + log_err(1, "cannot statfs %s", mntbuf[i].f_mntonname); + continue; + } + if (strcmp(statbuf.f_fstypename, "autofs") != 0) { + log_debugx("skipping %s, filesystem type is not autofs", + mntbuf[i].f_mntonname); + continue; + } flush_autofs(mntbuf[i].f_mntonname); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310240047.39O0lnZI005073>