From nobody Tue Oct 24 00:47:49 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 4SDth52r2Mz4xCwL; Tue, 24 Oct 2023 00:47:49 +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 4SDth52NpGz4PpV; Tue, 24 Oct 2023 00:47:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1698108469; 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=qA5DgNKZtUDZD+udUGM6tAW7JinBQKVw/HDIPdahBUw=; b=NqXSrP98vcNjdJnvGSAMQtWxKmls/kyynMCtUBP3KbUkxiL39lQFTZ1ygVGJl/t6SHhFUY XVtvo7gdZeJt5RD7nrX+updBErGrJKd95VFlrfHoXbBxWHN9rPE+ChkKwd0oYSxJfK/k5S ORyUssqJhDeGSM7Sn4iKVFRKhTWpbQb+c2cwgbiNq2Hyw92N0adEdjZh0URoY/iRBDnJg+ vI92Kn2qOFkQ5YAid8AI2ymUPTxWn6hw8M5LIVZPWtJPjuL660kLn+qgKxGqN/s9zjOGE0 kBIin2UxlI2jfkLjHMm4NCjTIOARzRKVCIYVHn64Lt5IYt29kyNACNUDyL/klQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1698108469; a=rsa-sha256; cv=none; b=lO6u4fMf7k5t0eB3BTP1YYdpl41v1Uo7QWhSDrcexnI2fY18eR/xQFR7sxnsm7TBIBAGaJ pQvHx+6lS5EDgexhTM+6JzCO8PXKI5KO6YAaxaCLtATW63OkPpulqMmNni1fsohQjFvryy hZ2ALa8SrADQcEehmkgb01fclfc1aNgKLzFBc4AlOFiS2RbVXG1p17xdEQQM9ZwGTdoLcg dD26YxheV4naTI2l0WEvZYTx3BG2P7T9AwNSY3R17Sr3AM3zkSEoV+beKa8eClAjlqj0uG q4fZ8DwbHbmWrxNgSYJl75981Ozp1AKrAqrvRw87wG/dMdXkHa9Da9vu59NHBQ== 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=1698108469; 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=qA5DgNKZtUDZD+udUGM6tAW7JinBQKVw/HDIPdahBUw=; b=va/0/xGzl64vyfF+q1E6tHFkSL56yINjbww/ie3f9rMEP2zg2WpqzpMOgab+vNRsJzW1hE W188RQlO5ziovBC7lz99AHkOoI30JBc/I5nq3x038tU6/hUMf+/SxcFbC+sHo+8ZJIInB8 WYLoRoO2+7zxbzJaZ6YWs3cLqb8Wn/YphPPJsLPtvikcKtX1l8yItnJLnUrVyW/7Cx+KHL Mq6/PT0UkJ2PU6Od5+GqPohGyHYYVcnFcLCUpNhRjXbuCIHclmCtPH0eRcPhg5qz8lCxUy qmuTSllZjNHFJbVG1bt6rQaoruNX1PigJrCqWxbQ1p5Hv55q+nAyp+GeQFlzFw== 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 4SDth51RjLz11Wp; Tue, 24 Oct 2023 00:47:49 +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 39O0lnuH005076; Tue, 24 Oct 2023 00:47:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 39O0lnZI005073; Tue, 24 Oct 2023 00:47:49 GMT (envelope-from git) Date: Tue, 24 Oct 2023 00:47:49 GMT Message-Id: <202310240047.39O0lnZI005073@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: 29dae977ae9b - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 29dae977ae9b01f429ae876743514da92ee8ecf4 Auto-Submitted: auto-generated The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=29dae977ae9b01f429ae876743514da92ee8ecf4 commit 29dae977ae9b01f429ae876743514da92ee8ecf4 Author: Andrew Gierth AuthorDate: 2023-07-10 15:09:56 +0000 Commit: Konstantin Belousov 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); }