Blame SOURCES/autofs-5.1.7-dont-try-umount-after-stat-ENOENT-fail.patch

29d2b9
autofs-5.1.7 - dont try umount after stat() ENOENT fail
29d2b9
29d2b9
From: Ian Kent <raven@themaw.net>
29d2b9
29d2b9
Coverity: Calling function "umount" that uses "me->key" after a check
29d2b9
	  function. This can cause a time-of-check, time-of-use race
29d2b9
	  condition.
29d2b9
29d2b9
Signed-off-by: Ian Kent <raven@themaw.net>
29d2b9
---
29d2b9
 CHANGELOG       |    1 +
29d2b9
 daemon/direct.c |    6 +++++-
29d2b9
 2 files changed, 6 insertions(+), 1 deletion(-)
29d2b9
29d2b9
diff --git a/CHANGELOG b/CHANGELOG
29d2b9
index 7add6c55..c7bc0c39 100644
29d2b9
--- a/CHANGELOG
29d2b9
+++ b/CHANGELOG
29d2b9
@@ -57,6 +57,7 @@
29d2b9
 - fix double unlock in parse_mount().
29d2b9
 - add length check in umount_subtree_mounts().
29d2b9
 - fix flags check in umount_multi().
29d2b9
+- dont try umount after stat() ENOENT fail.
29d2b9
 
29d2b9
 25/01/2021 autofs-5.1.7
29d2b9
 - make bind mounts propagation slave by default.
29d2b9
diff --git a/daemon/direct.c b/daemon/direct.c
29d2b9
index a33f9f91..3bd714e6 100644
29d2b9
--- a/daemon/direct.c
29d2b9
+++ b/daemon/direct.c
29d2b9
@@ -739,9 +739,13 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me)
29d2b9
 
29d2b9
 	ret = stat(me->key, &st);
29d2b9
 	if (ret == -1) {
29d2b9
+		int save_errno = errno;
29d2b9
+
29d2b9
 		error(ap->logopt,
29d2b9
 		     "failed to stat direct mount trigger %s", me->key);
29d2b9
-		goto out_umount;
29d2b9
+		if (save_errno != ENOENT)
29d2b9
+			goto out_umount;
29d2b9
+		goto out_err;
29d2b9
 	}
29d2b9
 
29d2b9
 	ops->open(ap->logopt, &ioctlfd, st.st_dev, me->key);