|
|
9a499a |
autofs-5.1.7 - fix inconsistent locking in umount_subtree_mounts()
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Some map entry cache locking inconsistencies have crept in.
|
|
|
9a499a |
|
|
|
9a499a |
In umount_subtree_mounts() the cache write lock should be held when
|
|
|
9a499a |
deleting multi-mount cache entries.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
daemon/automount.c | 42 ++++++++++++++++++++++++++++++------------
|
|
|
9a499a |
lib/mounts.c | 8 --------
|
|
|
9a499a |
3 files changed, 31 insertions(+), 20 deletions(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -14,6 +14,7 @@
|
|
|
9a499a |
- eliminate clean_stale_multi_triggers().
|
|
|
9a499a |
- simplify mount_subtree() mount check.
|
|
|
9a499a |
- fix mnts_get_expire_list() expire list construction.
|
|
|
9a499a |
+- fix inconsistent locking in umount_subtree_mounts().
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/automount.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/automount.c
|
|
|
9a499a |
@@ -527,8 +527,11 @@ static int umount_subtree_mounts(struct
|
|
|
9a499a |
struct mapent_cache *mc;
|
|
|
9a499a |
struct mapent *me;
|
|
|
9a499a |
unsigned int is_mm_root = 0;
|
|
|
9a499a |
+ int cur_state;
|
|
|
9a499a |
int left;
|
|
|
9a499a |
|
|
|
9a499a |
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
9a499a |
+
|
|
|
9a499a |
me = lookup_source_mapent(ap, path, LKP_DISTINCT);
|
|
|
9a499a |
if (!me) {
|
|
|
9a499a |
char *ind_key;
|
|
|
9a499a |
@@ -548,11 +551,11 @@ static int umount_subtree_mounts(struct
|
|
|
9a499a |
left = 0;
|
|
|
9a499a |
|
|
|
9a499a |
if (me && me->multi) {
|
|
|
9a499a |
- char root[PATH_MAX];
|
|
|
9a499a |
+ char root[PATH_MAX + 1];
|
|
|
9a499a |
+ char key[PATH_MAX + 1];
|
|
|
9a499a |
+ struct mapent *tmp;
|
|
|
9a499a |
+ int status;
|
|
|
9a499a |
char *base;
|
|
|
9a499a |
- int cur_state;
|
|
|
9a499a |
-
|
|
|
9a499a |
- pthread_cleanup_push(cache_lock_cleanup, mc);
|
|
|
9a499a |
|
|
|
9a499a |
if (!strchr(me->multi->key, '/'))
|
|
|
9a499a |
/* Indirect multi-mount root */
|
|
|
9a499a |
@@ -567,25 +570,40 @@ static int umount_subtree_mounts(struct
|
|
|
9a499a |
else
|
|
|
9a499a |
base = me->key + strlen(root);
|
|
|
9a499a |
|
|
|
9a499a |
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cur_state);
|
|
|
9a499a |
- /* Lock the closest parent nesting point for umount */
|
|
|
9a499a |
- cache_multi_writelock(me->parent);
|
|
|
9a499a |
- if (umount_multi_triggers(ap, me, root, base)) {
|
|
|
9a499a |
+ left = umount_multi_triggers(ap, me, root, base);
|
|
|
9a499a |
+ if (left) {
|
|
|
9a499a |
warn(ap->logopt,
|
|
|
9a499a |
"some offset mounts still present under %s", path);
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ strcpy(key, me->key);
|
|
|
9a499a |
+
|
|
|
9a499a |
+ cache_unlock(mc);
|
|
|
9a499a |
+ cache_writelock(mc);
|
|
|
9a499a |
+ tmp = cache_lookup_distinct(mc, key);
|
|
|
9a499a |
+ /* mapent went away while we waited? */
|
|
|
9a499a |
+ if (tmp != me) {
|
|
|
9a499a |
+ cache_unlock(mc);
|
|
|
9a499a |
+ pthread_setcancelstate(cur_state, NULL);
|
|
|
9a499a |
+ return 0;
|
|
|
9a499a |
+ }
|
|
|
9a499a |
+
|
|
|
9a499a |
+ if (!left && is_mm_root) {
|
|
|
9a499a |
+ status = cache_delete_offset_list(mc, me->key);
|
|
|
9a499a |
+ if (status != CHE_OK)
|
|
|
9a499a |
+ warn(ap->logopt, "couldn't delete offset list");
|
|
|
9a499a |
left++;
|
|
|
9a499a |
}
|
|
|
9a499a |
- cache_multi_unlock(me->parent);
|
|
|
9a499a |
+
|
|
|
9a499a |
if (ap->entry->maps &&
|
|
|
9a499a |
(ap->entry->maps->flags & MAP_FLAG_FORMAT_AMD))
|
|
|
9a499a |
cache_pop_mapent(me);
|
|
|
9a499a |
- pthread_setcancelstate(cur_state, NULL);
|
|
|
9a499a |
- pthread_cleanup_pop(0);
|
|
|
9a499a |
}
|
|
|
9a499a |
-
|
|
|
9a499a |
if (me)
|
|
|
9a499a |
cache_unlock(mc);
|
|
|
9a499a |
|
|
|
9a499a |
+ pthread_setcancelstate(cur_state, NULL);
|
|
|
9a499a |
+
|
|
|
9a499a |
if (left || is_autofs_fs)
|
|
|
9a499a |
return left;
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/lib/mounts.c
|
|
|
9a499a |
+++ autofs-5.1.4/lib/mounts.c
|
|
|
9a499a |
@@ -2730,9 +2730,6 @@ int umount_multi_triggers(struct autofs_
|
|
|
9a499a |
left = do_umount_multi_triggers(ap, me, root, base);
|
|
|
9a499a |
|
|
|
9a499a |
if (!left && me->multi == me) {
|
|
|
9a499a |
- struct mapent_cache *mc = me->mc;
|
|
|
9a499a |
- int status;
|
|
|
9a499a |
-
|
|
|
9a499a |
/*
|
|
|
9a499a |
* Special case.
|
|
|
9a499a |
* If we can't umount the root container then we can't
|
|
|
9a499a |
@@ -2750,11 +2747,6 @@ int umount_multi_triggers(struct autofs_
|
|
|
9a499a |
}
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
- /* We're done - clean out the offsets */
|
|
|
9a499a |
- status = cache_delete_offset_list(mc, me->key);
|
|
|
9a499a |
- if (status != CHE_OK)
|
|
|
9a499a |
- warn(ap->logopt, "couldn't delete offset list");
|
|
|
9a499a |
-
|
|
|
9a499a |
/* check for mounted mount entry and remove it if found */
|
|
|
9a499a |
mnts_remove_mount(root, MNTS_MOUNTED);
|
|
|
9a499a |
}
|