Blob Blame History Raw
autofs-5.1.7 - dont try umount after stat() ENOENT fail

From: Ian Kent <raven@themaw.net>

Coverity: Calling function "umount" that uses "me->key" after a check
	  function. This can cause a time-of-check, time-of-use race
	  condition.

Signed-off-by: Ian Kent <raven@themaw.net>
---
 CHANGELOG       |    1 +
 daemon/direct.c |    6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)

--- autofs-5.1.4.orig/CHANGELOG
+++ autofs-5.1.4/CHANGELOG
@@ -57,6 +57,7 @@
 - fix double unlock in parse_mount().
 - add length check in umount_subtree_mounts().
 - fix flags check in umount_multi().
+- dont try umount after stat() ENOENT fail.
 
 xx/xx/2018 autofs-5.1.5
 - fix flag file permission.
--- autofs-5.1.4.orig/daemon/direct.c
+++ autofs-5.1.4/daemon/direct.c
@@ -739,9 +739,13 @@ int mount_autofs_offset(struct autofs_po
 
 	ret = stat(me->key, &st);
 	if (ret == -1) {
+		int save_errno = errno;
+
 		error(ap->logopt,
 		     "failed to stat direct mount trigger %s", me->key);
-		goto out_umount;
+		if (save_errno != ENOENT)
+			goto out_umount;
+		goto out_err;
 	}
 
 	ops->open(ap->logopt, &ioctlfd, st.st_dev, me->key);