From nobody Tue Oct 24 00:46:32 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SDtfc2fJSz4xDFB; Tue, 24 Oct 2023 00:46:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SDtfc284Vz4N2J; Tue, 24 Oct 2023 00:46:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698108392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n75fanb2R+3OAUA9Ag4tOqgpmNKnj2cNGvuL9KALNSg=; b=CN7Fmt/0C7TilUT9eIkU51p5K16wV/okeytrQnvPoLORYeVvfQb1R3fGMDxbyYDWEv9M+0 evSeuhksJHsG7Q79VAMh2IlGJRmtqTuTrYWAzy87EtNlIQQYNYGlhH7gUnQdSqHlmis/4a 9TcSpzZ32gAN9j2KpIIxV8fnq45KZE/UxyxDjPBHo0+L/I/ex7TwANsLS2ErJm0RdjY/UC nl00YlvnocMdJ0woqM9QfhHMIyNPbbX/UjRqw2m6c6ZEX3bI5U84AzmnmasuK1FOCGda+s 1h4By77g8zHHxd6OJS44zXzKFrFxleezm5YSMYk7IWwS7FdrDFvIP4o7e3qEkA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698108392; a=rsa-sha256; cv=none; b=dmlpg3tJbjy11GowoKDj1NpjUR8vYLBp92b/xSHMBv3lSjI1tV47PxQIbNSlfd7zcRTT3V XDOxz62PVJqIYKK/PIg/WgPkYx8fEQ6NJsy7BNb4n4VLdTV4Qza2cb6lAnskrXuvQ6j+Cy lGWaRZlzL5AtMZFekQ2WTXL+uwhljCgtMs4kSK+hAh2gKni5LRZY9H3GbsxSgHrQ0NHaEU k4LC4zQ2tzQAIjA4t+aY/+N3bmHkxRFL34ewYAO4DXrwFjuRTG/VGNniDOEruGTGJg7bFA iryIu8rrcsB0vpcBNGtJX9XrQBQsi9d8NY/lgCAYAS3BzoIeMbk7vgPP74SbpA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698108392; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=n75fanb2R+3OAUA9Ag4tOqgpmNKnj2cNGvuL9KALNSg=; b=rtkj3+NjH2Y1N1aZyZ4UBobw1FEeQG07rqvr27KPNxLhRBn5dejTj/lV/4QtJDHs9bGNSR pCXuiXa4b4EzGfP/SfSsUEQT6NDacnrZVDq/3nW6MmCuebBGNNnU6qnkzoD6Ttc3toFmF6 DTsiER1CH+r6gz7qujGMUOxpNmi5zAR3hzDcQx/+pyyqOiTp6hou/yV13TrrsBf9DUCuaN 19F/8pK0U74rK6LYmNlwZHTMjDNo5a7NnQdDy5qDCZlBHf/0aEA/5o8K6fnhO+GrPnP7HJ GC4RYWl+S8/1tUSjna4aQkqJzb7lLHNlVXV7giezrX9kct8UVmy9OE6wLKXgjg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SDtfc181Cz12LB; Tue, 24 Oct 2023 00:46:32 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 39O0kWdi004390; Tue, 24 Oct 2023 00:46:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39O0kWHN004387; Tue, 24 Oct 2023 00:46:32 GMT (envelope-from git) Date: Tue, 24 Oct 2023 00:46:32 GMT Message-Id: <202310240046.39O0kWHN004387@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 361f7820cde9 - stable/14 - automount: check for mounted-over autofs instances on flush List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 361f7820cde9cc9e9eb7118155b6a39c1a52ef9d Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=361f7820cde9cc9e9eb7118155b6a39c1a52ef9d commit 361f7820cde9cc9e9eb7118155b6a39c1a52ef9d Author: Andrew Gierth AuthorDate: 2023-07-10 15:09:56 +0000 Commit: Konstantin Belousov 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(+) 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); }