From 30a9f0e2f98a6a0a21b2a194817fde635c00915b Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Sep 03 2009 08:17:07 +0000 Subject: - fix libxml2 non-thread-safe calls. - fix direct map cache locking. - fix patch "dont umount existing direct mount on reread" deadlock. --- diff --git a/autofs-5.0.4-fix-direct-map-cache-locking.patch b/autofs-5.0.4-fix-direct-map-cache-locking.patch new file mode 100644 index 0000000..5693fa9 --- /dev/null +++ b/autofs-5.0.4-fix-direct-map-cache-locking.patch @@ -0,0 +1,61 @@ +autofs-5.0.4 - fix direct map cache locking + +From: Ian Kent + +Some time during the recent round of updates some locking of the +null map and the direct map entry caches was removed. This patch +adds it back again. +--- + + CHANGELOG | 1 + + daemon/direct.c | 6 ++++++ + 2 files changed, 7 insertions(+), 0 deletions(-) + + +diff --git a/CHANGELOG b/CHANGELOG +index af7792d..82ebc83 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -60,6 +60,7 @@ + - don't block signals we expect to dump core. + - fix pthread push order in expire_proc_direct(). + - fix libxml2 non-thread-safe calls. ++- fix direct map cache locking. + + 4/11/2008 autofs-5.0.4 + ----------------------- +diff --git a/daemon/direct.c b/daemon/direct.c +index 0f33d03..0c78627 100644 +--- a/daemon/direct.c ++++ b/daemon/direct.c +@@ -470,6 +470,8 @@ int mount_autofs_direct(struct autofs_point *ap) + pthread_cleanup_push(master_source_lock_cleanup, ap->entry); + master_source_readlock(ap->entry); + nc = ap->entry->master->nc; ++ cache_readlock(nc); ++ pthread_cleanup_push(cache_lock_cleanup, nc); + map = ap->entry->maps; + while (map) { + /* +@@ -482,6 +484,8 @@ int mount_autofs_direct(struct autofs_point *ap) + } + + mc = map->mc; ++ cache_readlock(mc); ++ pthread_cleanup_push(cache_lock_cleanup, mc); + me = cache_enumerate(mc, NULL); + while (me) { + ne = cache_lookup_distinct(nc, me->key); +@@ -509,10 +513,12 @@ int mount_autofs_direct(struct autofs_point *ap) + + me = cache_enumerate(mc, me); + } ++ pthread_cleanup_pop(1); + map = map->next; + } + pthread_cleanup_pop(1); + pthread_cleanup_pop(1); ++ pthread_cleanup_pop(1); + + return 0; + } diff --git a/autofs-5.0.4-fix-dont-umount-existing-direct-mount-on-reread.patch b/autofs-5.0.4-fix-dont-umount-existing-direct-mount-on-reread.patch new file mode 100644 index 0000000..e5a7ab9 --- /dev/null +++ b/autofs-5.0.4-fix-dont-umount-existing-direct-mount-on-reread.patch @@ -0,0 +1,53 @@ +autofs-5.0.4 - fix dont umount existing direct mount on reread + +From: Ian Kent + +A recent problem where we incorrectly umounted direct mounts on map +re-read, when the map name in the master map has changed, checks for +the stale entry in an old map source and updates the new entry from +information in the the stale entry. But this check can also match +an entry that has been removed from a direct map whose name hasn't +changed which leads to a deadlock when we try and take the cache +write lock on the (alleged) stale cache to update the new entry. +This is because, in this case, the cache we want to lock is in +fact the one we are reading and we already hold a read lock on it. +--- + + CHANGELOG | 1 + + daemon/state.c | 10 ++++++++++ + 2 files changed, 11 insertions(+), 0 deletions(-) + + +diff --git a/CHANGELOG b/CHANGELOG +index 82ebc83..929a21f 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -61,6 +61,7 @@ + - fix pthread push order in expire_proc_direct(). + - fix libxml2 non-thread-safe calls. + - fix direct map cache locking. ++- fix dont umount existing direct mount on reread. + + 4/11/2008 autofs-5.0.4 + ----------------------- +diff --git a/daemon/state.c b/daemon/state.c +index 84ccba3..71af46a 100644 +--- a/daemon/state.c ++++ b/daemon/state.c +@@ -389,6 +389,16 @@ static void do_readmap_mount(struct autofs_point *ap, struct mnt_list *mnts, + * an empty cache awaiting a map re-load. + */ + valid = lookup_source_valid_mapent(ap, me->key, LKP_DISTINCT); ++ if (valid && valid->mc == me->mc) { ++ /* ++ * We've found a map entry that has been removed from ++ * the current cache so there is no need to update it. ++ * The stale entry will be dealt with when we prune the ++ * cache later. ++ */ ++ cache_unlock(valid->mc); ++ valid = NULL; ++ } + if (valid) { + struct mapent_cache *vmc = valid->mc; + cache_unlock(vmc); diff --git a/autofs-5.0.4-fix-libxml2-non-thread-safe-calls.patch b/autofs-5.0.4-fix-libxml2-non-thread-safe-calls.patch new file mode 100644 index 0000000..485fcb6 --- /dev/null +++ b/autofs-5.0.4-fix-libxml2-non-thread-safe-calls.patch @@ -0,0 +1,100 @@ +autofs-5.0.4 - fix libxml2 non-thread-safe calls + +From: Ian Kent + +The libxml2 call xmlCleanupParser() is definitely not thread safe. +This patch moves it and the xmlInitParser() call to the location +of the code to workaround the libxml2 incorrect TSD handling so +they are called only at start and at exit. +--- + + CHANGELOG | 1 + + daemon/Makefile | 7 +++++++ + daemon/automount.c | 7 ++++++- + modules/lookup_ldap.c | 2 -- + 4 files changed, 14 insertions(+), 3 deletions(-) + + +diff --git a/CHANGELOG b/CHANGELOG +index 4491449..af7792d 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -59,6 +59,7 @@ + - fix an RPC fd leak. + - don't block signals we expect to dump core. + - fix pthread push order in expire_proc_direct(). ++- fix libxml2 non-thread-safe calls. + + 4/11/2008 autofs-5.0.4 + ----------------------- +diff --git a/daemon/Makefile b/daemon/Makefile +index 9c2d858..371ec72 100644 +--- a/daemon/Makefile ++++ b/daemon/Makefile +@@ -22,6 +22,13 @@ CFLAGS += -DVERSION_STRING=\"$(version)\" + LDFLAGS += -rdynamic + LIBS = -ldl + ++ifeq ($(LDAP), 1) ++ ifeq ($(SASL), 1) ++ CFLAGS += $(XML_FLAGS) ++ LIBS += $(XML_LIBS) ++ endif ++endif ++ + all: automount + + automount: $(OBJS) $(AUTOFS_LIB) +diff --git a/daemon/automount.c b/daemon/automount.c +index 6759883..979ecd6 100644 +--- a/daemon/automount.c ++++ b/daemon/automount.c +@@ -40,6 +40,7 @@ + #include "automount.h" + #ifdef LIBXML2_WORKAROUND + #include ++#include + #endif + + const char *program; /* Initialized with argv[0] */ +@@ -2113,6 +2114,8 @@ int main(int argc, char *argv[]) + void *dh_xml2 = dlopen("libxml2.so", RTLD_NOW); + if (!dh_xml2) + dh_xml2 = dlopen("libxml2.so.2", RTLD_NOW); ++ if (dh_xml2) ++ xmlInitParser(); + #endif + #ifdef TIRPC_WORKAROUND + void *dh_tirpc = dlopen("libitirpc.so", RTLD_NOW); +@@ -2156,8 +2159,10 @@ int main(int argc, char *argv[]) + dlclose(dh_tirpc); + #endif + #ifdef LIBXML2_WORKAROUND +- if (dh_xml2) ++ if (dh_xml2) { ++ xmlCleanupParser(); + dlclose(dh_xml2); ++ } + #endif + close_ioctl_ctl(); + +diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c +index 8f352d6..2ecf5fe 100644 +--- a/modules/lookup_ldap.c ++++ b/modules/lookup_ldap.c +@@ -897,7 +897,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) + return -1; + } + +- xmlInitParser(); + doc = xmlParseFile(auth_conf); + if (!doc) { + error(logopt, MODPREFIX +@@ -1069,7 +1068,6 @@ int parse_ldap_config(unsigned logopt, struct lookup_context *ctxt) + + out: + xmlFreeDoc(doc); +- xmlCleanupParser(); + + if (fallback) + return 0; diff --git a/autofs.spec b/autofs.spec index fcc1eaf..aefe87b 100644 --- a/autofs.spec +++ b/autofs.spec @@ -4,7 +4,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.0.4 -Release: 37 +Release: 39 Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -72,6 +72,9 @@ Patch59: autofs-5.0.4-fix-map-type-info-parse-error-update.patch Patch60: autofs-5.0.4-fix-rpc-fd-leak.patch Patch61: autofs-5.0.4-allow-automount-daemon-to-dump-core.patch Patch62: autofs-5.0.4-fix-pthread-push-order-in-expire_proc_direct.patch +Patch63: autofs-5.0.4-fix-libxml2-non-thread-safe-calls.patch +Patch64: autofs-5.0.4-fix-direct-map-cache-locking.patch +Patch65: autofs-5.0.4-fix-dont-umount-existing-direct-mount-on-reread.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel module-init-tools util-linux nfs-utils e2fsprogs libtirpc-devel Requires: kernel >= 2.6.17 @@ -175,6 +178,9 @@ echo %{version}-%{release} > .version %patch60 -p1 %patch61 -p1 %patch62 -p1 +%patch63 -p1 +%patch64 -p1 +%patch65 -p1 %build #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir} @@ -227,6 +233,11 @@ fi %{_libdir}/autofs/ %changelog +* Thu Sep 3 2009 Ian Kent - 1:5.0.4-39 +- fix libxml2 non-thread-safe calls. +- fix direct map cache locking. +- fix patch "dont umount existing direct mount on reread" deadlock. + * Fri Jul 24 2009 Fedora Release Engineering - 1:5.0.4-37 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild