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

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