|
|
cd8711 |
autofs-5.1.8 - fix hosts map deadlock on restart
|
|
|
cd8711 |
|
|
|
cd8711 |
From: Ian Kent <raven@themaw.net>
|
|
|
cd8711 |
|
|
|
cd8711 |
When starting automount(8) with a hosts map that has mounts that were
|
|
|
cd8711 |
in use at the last exit a deadlock can occur.
|
|
|
cd8711 |
|
|
|
cd8711 |
In this case automount(8) will perform the same steps but not actually
|
|
|
cd8711 |
perform the mount to re-construct the context of each mount. But, with
|
|
|
cd8711 |
the hosts map, that leads to calling back into the sun parse module
|
|
|
cd8711 |
while holding the map module read lock which will again try and take
|
|
|
cd8711 |
the write lock.
|
|
|
cd8711 |
|
|
|
cd8711 |
Fix this by only taking the write lock in the mount code path if the
|
|
|
cd8711 |
module handle has not already been opened.
|
|
|
cd8711 |
|
|
|
cd8711 |
Signed-off-by: Ian Kent <raven@themaw.net>
|
|
|
cd8711 |
---
|
|
|
cd8711 |
CHANGELOG | 1 +
|
|
|
cd8711 |
daemon/lookup.c | 22 ++++++++++++----------
|
|
|
cd8711 |
modules/parse_amd.c | 18 ++++++++++--------
|
|
|
cd8711 |
3 files changed, 23 insertions(+), 18 deletions(-)
|
|
|
cd8711 |
|
|
|
cd8711 |
--- autofs-5.1.4.orig/CHANGELOG
|
|
|
cd8711 |
+++ autofs-5.1.4/CHANGELOG
|
|
|
cd8711 |
@@ -99,6 +99,7 @@
|
|
|
cd8711 |
- fix parse module instance mutex naming.
|
|
|
cd8711 |
- serialise lookup module open and reinit.
|
|
|
cd8711 |
- coverity fix for invalid access.
|
|
|
cd8711 |
+- fix hosts map deadlock on restart.
|
|
|
cd8711 |
|
|
|
cd8711 |
xx/xx/2018 autofs-5.1.5
|
|
|
cd8711 |
- fix flag file permission.
|
|
|
cd8711 |
--- autofs-5.1.4.orig/daemon/lookup.c
|
|
|
cd8711 |
+++ autofs-5.1.4/daemon/lookup.c
|
|
|
cd8711 |
@@ -815,19 +815,21 @@ int do_lookup_mount(struct autofs_point
|
|
|
cd8711 |
struct lookup_mod *lookup;
|
|
|
cd8711 |
int status;
|
|
|
cd8711 |
|
|
|
cd8711 |
- map_module_writelock(map);
|
|
|
cd8711 |
if (!map->lookup) {
|
|
|
cd8711 |
- status = open_lookup(map->type, "",
|
|
|
cd8711 |
- map->format, map->argc, map->argv, &lookup);
|
|
|
cd8711 |
- if (status != NSS_STATUS_SUCCESS) {
|
|
|
cd8711 |
- map_module_unlock(map);
|
|
|
cd8711 |
- debug(ap->logopt,
|
|
|
cd8711 |
- "lookup module %s open failed", map->type);
|
|
|
cd8711 |
- return status;
|
|
|
cd8711 |
+ map_module_writelock(map);
|
|
|
cd8711 |
+ if (!map->lookup) {
|
|
|
cd8711 |
+ status = open_lookup(map->type, "",
|
|
|
cd8711 |
+ map->format, map->argc, map->argv, &lookup);
|
|
|
cd8711 |
+ if (status != NSS_STATUS_SUCCESS) {
|
|
|
cd8711 |
+ map_module_unlock(map);
|
|
|
cd8711 |
+ debug(ap->logopt,
|
|
|
cd8711 |
+ "lookup module %s open failed", map->type);
|
|
|
cd8711 |
+ return status;
|
|
|
cd8711 |
+ }
|
|
|
cd8711 |
+ map->lookup = lookup;
|
|
|
cd8711 |
}
|
|
|
cd8711 |
- map->lookup = lookup;
|
|
|
cd8711 |
+ map_module_unlock(map);
|
|
|
cd8711 |
}
|
|
|
cd8711 |
- map_module_unlock(map);
|
|
|
cd8711 |
|
|
|
cd8711 |
master_source_current_wait(ap->entry);
|
|
|
cd8711 |
ap->entry->current = map;
|
|
|
cd8711 |
--- autofs-5.1.4.orig/modules/parse_amd.c
|
|
|
cd8711 |
+++ autofs-5.1.4/modules/parse_amd.c
|
|
|
cd8711 |
@@ -1370,17 +1370,19 @@ static int do_host_mount(struct autofs_p
|
|
|
cd8711 |
}
|
|
|
cd8711 |
}
|
|
|
cd8711 |
|
|
|
cd8711 |
- map_module_writelock(instance);
|
|
|
cd8711 |
if (!instance->lookup) {
|
|
|
cd8711 |
- status = open_lookup("hosts", MODPREFIX, NULL, argc, pargv, &lookup);
|
|
|
cd8711 |
- if (status != NSS_STATUS_SUCCESS) {
|
|
|
cd8711 |
- map_module_unlock(instance);
|
|
|
cd8711 |
- debug(ap->logopt, "open lookup module hosts failed");
|
|
|
cd8711 |
- goto out;
|
|
|
cd8711 |
+ map_module_writelock(instance);
|
|
|
cd8711 |
+ if (!instance->lookup) {
|
|
|
cd8711 |
+ status = open_lookup("hosts", MODPREFIX, NULL, argc, pargv, &lookup);
|
|
|
cd8711 |
+ if (status != NSS_STATUS_SUCCESS) {
|
|
|
cd8711 |
+ map_module_unlock(instance);
|
|
|
cd8711 |
+ debug(ap->logopt, "open lookup module hosts failed");
|
|
|
cd8711 |
+ goto out;
|
|
|
cd8711 |
+ }
|
|
|
cd8711 |
+ instance->lookup = lookup;
|
|
|
cd8711 |
}
|
|
|
cd8711 |
- instance->lookup = lookup;
|
|
|
cd8711 |
+ map_module_unlock(instance);
|
|
|
cd8711 |
}
|
|
|
cd8711 |
- map_module_unlock(instance);
|
|
|
cd8711 |
|
|
|
cd8711 |
cache_writelock(source->mc);
|
|
|
cd8711 |
me = cache_lookup_distinct(source->mc, name);
|