From nobody Tue Oct 17 16:41:40 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 4S909x0zSlz4xkD3; Tue, 17 Oct 2023 16:41:41 +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 4S909x01dCz4QwX; Tue, 17 Oct 2023 16:41:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1697560901; 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=gfRbJRYoax61Os9vKc3BXBH60LLU5Xb5sAOe4decnJA=; b=WVIHuFG/Yn9aZynmh7spt8YRWnAUZtoV3s9u3hDHZVRrJesHemr6PIECPhugg2iV2TO1qZ nLYX4xZ8Y75ro52K/8Wmk0bKVrShWtwLvJteu5foLiKJSj8GMsTU/YHmym8YjjSlWkPK8I nSaiMb7s7mEHWmF4WTBD46210MoVnGTf4nRZsUwvZDRyHkuyH6bcuHozEMI/zGfmJHMwQT U0oTiJwdhzGxnzkJWQ782Bya89jmhf3jt0T93mpbEp79YzTqodSNaRxMVmsuPKUCtlykps 7YICAF6jnySt8lfUPFY9drkPb09YfJ5Ta1brWOXO9b0ekxiN96DAYK4cklvC6A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1697560901; a=rsa-sha256; cv=none; b=CX0ydu1dpyJqSw5gxrEo9jKieFBH/iUF/9nq6ruArj7vU1H+jdapiKgOuEsewdORbIsdqE uWQ6X40+q17QRpBZo78i2dwfchE/eUXpki8VsTThzs20RvTUZ1NJu0Eqv9M292ub1u2/yP /+oOLOIQsAOboAU54hcVFJ8n2bvjEueX1ZJu9FXrImlsxsCUrR5Kk6ZkwKWkRd2W7+nfcG eiQm/oC1sx1Nw6ne8faB8X3PrmGOtjeU6gpP/9RHjIgE1HgjLmzrhhcnVvOrHzl8f/cq/N +y126KwKf9/6Gz9aG7Er8pPWlBBc4XTsY0DAplejWQ4n89/4JGuFKxstT84rUg== 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=1697560901; 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=gfRbJRYoax61Os9vKc3BXBH60LLU5Xb5sAOe4decnJA=; b=eGWX5z9eX/2gaXLnTCLbqbTYP7wIaGmlI197X1D/rzUz/I7JTxD8zcyhjcGoOO7ANSr3qU +aoTo0Q7RT2YdGeb9tk6Nhe/X3qIsNztdeQDavBCJkm+/E65zLlDlwAiGbcfqZspOknHRQ WrMNu00JH5AjzyoJKJEc82idfQlclq9kPA5Um0La9EdaN2VYHjjVYu8cPLBoGtyNuNlFy1 r4MBGrxSCs16d3dUuGr9yecp8JRVv38PCGVetAolWbo8KZSmjoiJ4UDTFafwnxvrj1OYHO a9NYuRKx4Qf0S2kamnm7nsMJhGeqe1AgQxvLMioI/5N1YyU/oVmGsGZnkUq1eA== 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 4S909w5lbHzX2S; Tue, 17 Oct 2023 16:41:40 +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 39HGfeaA009957; Tue, 17 Oct 2023 16:41:40 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39HGfeCS009954; Tue, 17 Oct 2023 16:41:40 GMT (envelope-from git) Date: Tue, 17 Oct 2023 16:41:40 GMT Message-Id: <202310171641.39HGfeCS009954@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 21b8e363c4eb - main - 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/main X-Git-Reftype: branch X-Git-Commit: 21b8e363c4eb24c0a5659101603cc08a86d87759 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=21b8e363c4eb24c0a5659101603cc08a86d87759 commit 21b8e363c4eb24c0a5659101603cc08a86d87759 Author: Andrew Gierth AuthorDate: 2023-07-10 15:09:56 +0000 Commit: Konstantin Belousov 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(+) 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); }