|
|
9a499a |
autofs-5.1.7 - refactor lookup_prune_one_cache() a bit
|
|
|
9a499a |
|
|
|
9a499a |
From: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
|
|
|
9a499a |
Coverity: use: Using an unreliable value of "me" inside the second locked
|
|
|
9a499a |
section.
|
|
|
9a499a |
|
|
|
9a499a |
Change lookup_prune_one_cache() a little, move the location the next
|
|
|
9a499a |
key is set (before releasing the lock) and add a comment explaining
|
|
|
9a499a |
why we don't care about the side effects of the read lock release/
|
|
|
9a499a |
write lock aquire/write lock release/read lock reaquire.
|
|
|
9a499a |
|
|
|
9a499a |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
9a499a |
---
|
|
|
9a499a |
CHANGELOG | 1 +
|
|
|
9a499a |
daemon/lookup.c | 20 +++++++++++++++++++-
|
|
|
9a499a |
2 files changed, 20 insertions(+), 1 deletion(-)
|
|
|
9a499a |
|
|
|
9a499a |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
9a499a |
+++ autofs-5.1.4/CHANGELOG
|
|
|
9a499a |
@@ -63,6 +63,7 @@
|
|
|
9a499a |
- fix arg not used in error print.
|
|
|
9a499a |
- fix missing lock release in mount_subtree().
|
|
|
9a499a |
- fix double free in parse_mapent().
|
|
|
9a499a |
+- refactor lookup_prune_one_cache() a bit.
|
|
|
9a499a |
|
|
|
9a499a |
xx/xx/2018 autofs-5.1.5
|
|
|
9a499a |
- fix flag file permission.
|
|
|
9a499a |
--- autofs-5.1.4.orig/daemon/lookup.c
|
|
|
9a499a |
+++ autofs-5.1.4/daemon/lookup.c
|
|
|
9a499a |
@@ -1383,7 +1383,6 @@ void lookup_prune_one_cache(struct autof
|
|
|
9a499a |
}
|
|
|
9a499a |
|
|
|
9a499a |
key = strdup(me->key);
|
|
|
9a499a |
- me = cache_enumerate(mc, me);
|
|
|
9a499a |
/* Don't consider any entries with a wildcard */
|
|
|
9a499a |
if (!key || strchr(key, '*')) {
|
|
|
9a499a |
if (key)
|
|
|
9a499a |
@@ -1430,6 +1429,7 @@ void lookup_prune_one_cache(struct autof
|
|
|
9a499a |
if (valid)
|
|
|
9a499a |
cache_unlock(valid->mc);
|
|
|
9a499a |
|
|
|
9a499a |
+ me = cache_enumerate(mc, me);
|
|
|
9a499a |
if (me)
|
|
|
9a499a |
next_key = strdup(me->key);
|
|
|
9a499a |
|
|
|
9a499a |
@@ -1464,6 +1464,24 @@ void lookup_prune_one_cache(struct autof
|
|
|
9a499a |
next:
|
|
|
9a499a |
cache_readlock(mc);
|
|
|
9a499a |
if (next_key) {
|
|
|
9a499a |
+ /* The lock release and reaquire above can mean
|
|
|
9a499a |
+ * a number of things could happen.
|
|
|
9a499a |
+ *
|
|
|
9a499a |
+ * First, mapents could be added between the
|
|
|
9a499a |
+ * current mapent and the mapent of next_key.
|
|
|
9a499a |
+ * Don't care about that because there's no
|
|
|
9a499a |
+ * need to prune newly added entries.
|
|
|
9a499a |
+ *
|
|
|
9a499a |
+ * Second, the next mapent data could have
|
|
|
9a499a |
+ * changed. Don't care about that either since
|
|
|
9a499a |
+ * we are looking to prune stale map entries
|
|
|
9a499a |
+ * and don't care when they become stale.
|
|
|
9a499a |
+ *
|
|
|
9a499a |
+ * Finally, the mapent of next_key could have
|
|
|
9a499a |
+ * gone away. Again don't care about this either,
|
|
|
9a499a |
+ * the loop will exit prematurely so just wait
|
|
|
9a499a |
+ * until the next prune and try again.
|
|
|
9a499a |
+ */
|
|
|
9a499a |
me = cache_lookup_distinct(mc, next_key);
|
|
|
9a499a |
free(next_key);
|
|
|
9a499a |
}
|