Blame SOURCES/autofs-5.1.6-fix-program-map-multi-mount-lookup-after-mount-fail.patch

beb904
autofs-5.1.6 - fix program map multi-mount lookup after mount fail
beb904
beb904
From: Ian Kent <raven@themaw.net>
beb904
beb904
For the case of a singleton multi-mount program map lookup following
beb904
a mount fail (and the negative timeout has passed) the lookup key is
beb904
what's expected for an indirect map key but the the root offset map
beb904
entry already exists. This causes autofs to think it has an incorrect
beb904
lookup key and it fails the lookup when it should take the opptunity
beb904
to delete and update the cache entry since it's not actually in use
beb904
yet.
beb904
beb904
If a check is done to see if the lookup is for the root offset,
beb904
deleting the entry fails because it contains an offset. Later when
beb904
parsing is done the offset will get updated and can get out of sync
beb904
with the entry of the multi-mount owner. That's not a problem as the
beb904
offsets would be deleted on eventual expire but it's best to clean
beb904
out the entry and start a fresh so the most up to date map entry
beb904
is being used.
beb904
beb904
Signed-off-by: Ian Kent <raven@themaw.net>
beb904
---
beb904
 CHANGELOG                |    1 +
beb904
 modules/lookup_program.c |    7 +++++--
beb904
 2 files changed, 6 insertions(+), 2 deletions(-)
beb904
beb904
--- autofs-5.1.4.orig/CHANGELOG
beb904
+++ autofs-5.1.4/CHANGELOG
beb904
@@ -27,6 +27,7 @@
beb904
 - rename path to m_offset in update_offset_entry().
beb904
 - don't pass root to do_mount_autofs_offset().
beb904
 - rename tree implementation functions.
beb904
+- fix program map multi-mount lookup after mount fail.
beb904
 
beb904
 xx/xx/2018 autofs-5.1.5
beb904
 - fix flag file permission.
beb904
--- autofs-5.1.4.orig/modules/lookup_program.c
beb904
+++ autofs-5.1.4/modules/lookup_program.c
beb904
@@ -664,7 +664,7 @@ int lookup_mount(struct autofs_point *ap
beb904
 				 name_len, ent, ctxt->parse->context);
beb904
 			goto out_free;
beb904
 		} else {
beb904
-			if (me->multi) {
beb904
+			if (me->multi && me->multi != me) {
beb904
 				cache_unlock(mc);
beb904
 				warn(ap->logopt, MODPREFIX
beb904
 				     "unexpected lookup for active multi-mount"
beb904
@@ -674,8 +674,11 @@ int lookup_mount(struct autofs_point *ap
beb904
 			cache_unlock(mc);
beb904
 			cache_writelock(mc);
beb904
 			me = cache_lookup_distinct(mc, name);
beb904
-			if (me)
beb904
+			if (me) {
beb904
+				if (me->multi)
beb904
+					cache_delete_offset_list(mc, name);
beb904
 				cache_delete(mc, name);
beb904
+			}
beb904
 			cache_unlock(mc);
beb904
 		}
beb904
 	}