From 180ae20843472710ab1422c35d9a25672d25979c Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Wed, 16 Feb 2022 04:20:04 +0000 Subject: [PATCH] import autofs-5.1.4-81.el8 --- ...ific-with-NULL-key_thread_attempt_id.patch | 35 ++++++++ ...-fail-on-duplicate-host-export-entry.patch | 46 ++++++++++ ...under-run-in-cache_get_offset_parent.patch | 36 ++++++++ ...5.1.8-fix-memory-leak-in-xdr_exports.patch | 40 +++++++++ ...t-fail-handling-of-last-offset-mount.patch | 38 ++++++++ ...5.1.8-fix-root-offset-error-handling.patch | 86 +++++++++++++++++++ ...fs-5.1.8-fix-sysconf-return-handling.patch | 64 ++++++++++++++ ...ee-in-tree_mapent_delete_offset_tree.patch | 55 ++++++++++++ ...fs-5.1.8-simplify-cache_add-a-little.patch | 44 ++++++++++ SPECS/autofs.spec | 35 +++++++- 10 files changed, 478 insertions(+), 1 deletion(-) create mode 100644 SOURCES/autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch create mode 100644 SOURCES/autofs-5.1.8-dont-fail-on-duplicate-host-export-entry.patch create mode 100644 SOURCES/autofs-5.1.8-fix-loop-under-run-in-cache_get_offset_parent.patch create mode 100644 SOURCES/autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch create mode 100644 SOURCES/autofs-5.1.8-fix-nonstrict-fail-handling-of-last-offset-mount.patch create mode 100644 SOURCES/autofs-5.1.8-fix-root-offset-error-handling.patch create mode 100644 SOURCES/autofs-5.1.8-fix-sysconf-return-handling.patch create mode 100644 SOURCES/autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patch create mode 100644 SOURCES/autofs-5.1.8-simplify-cache_add-a-little.patch diff --git a/SOURCES/autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch b/SOURCES/autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch new file mode 100644 index 0000000..b7aaa62 --- /dev/null +++ b/SOURCES/autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch @@ -0,0 +1,35 @@ +autofs-5.1.8 - avoid calling pthread_getspecific() with NULL key_thread_attempt_id + +From: Ian Kent + +Don't call pthread_getspecific() if key_thread_attempt_id is NULL in +case the pthread_getspecific() implementation doesn't check for this. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/log.c | 3 +++ + 2 files changed, 4 insertions(+) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -90,6 +90,7 @@ + - simplify cache_add() a little. + - fix use after free in tree_mapent_delete_offset_tree(). + - fix memory leak in xdr_exports(). ++- avoid calling pthread_getspecific() with NULL key_thread_attempt_id. + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/log.c ++++ autofs-5.1.4/lib/log.c +@@ -38,6 +38,9 @@ static char *prepare_attempt_prefix(cons + char buffer[ATTEMPT_ID_SIZE + 1]; + char *prefixed_msg = NULL; + ++ if (!key_thread_attempt_id) ++ return NULL; ++ + attempt_id = pthread_getspecific(key_thread_attempt_id); + if (attempt_id) { + int len = sizeof(buffer) + 1 + strlen(msg) + 1; diff --git a/SOURCES/autofs-5.1.8-dont-fail-on-duplicate-host-export-entry.patch b/SOURCES/autofs-5.1.8-dont-fail-on-duplicate-host-export-entry.patch new file mode 100644 index 0000000..0151500 --- /dev/null +++ b/SOURCES/autofs-5.1.8-dont-fail-on-duplicate-host-export-entry.patch @@ -0,0 +1,46 @@ +autofs-5.1.8 - dont fail on duplicate host export entry + +From: Ian Kent + +If we encounter a duplicate host export entry don't fail, just ignore +it and return the duplicate. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 6 ++++-- + 2 files changed, 5 insertions(+), 2 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -85,6 +85,7 @@ + - fix double quoting of ampersand in auto.smb as well. + - fix root offset error handling. + - fix nonstrict fail handling of last offset mount. ++- dont fail on duplicate offset entry tree add. + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/mounts.c ++++ autofs-5.1.4/lib/mounts.c +@@ -1341,7 +1341,7 @@ static struct tree_node *tree_add_node(s + } + + if (!eq) +- error(LOGOPT_ANY, "cannot add duplicate entry to tree"); ++ return p; + else { + if (eq < 0) + return tree_add_left(p, ptr); +@@ -1515,8 +1515,10 @@ static int tree_host_cmp(struct tree_nod + int eq; + + eq = strcmp(exp->dir, n_exp->dir); +- if (!eq) ++ if (!eq) { ++ error(LOGOPT_ANY, "duplicate entry %s ignored", exp->dir); + return 0; ++ } + return (exp_len < n_exp_len) ? -1 : 1; + } + diff --git a/SOURCES/autofs-5.1.8-fix-loop-under-run-in-cache_get_offset_parent.patch b/SOURCES/autofs-5.1.8-fix-loop-under-run-in-cache_get_offset_parent.patch new file mode 100644 index 0000000..c244254 --- /dev/null +++ b/SOURCES/autofs-5.1.8-fix-loop-under-run-in-cache_get_offset_parent.patch @@ -0,0 +1,36 @@ +autofs-5.1.8 - fix loop under run in cache_get_offset_parent() + +From: Frank Sorenson + +To avoid reading memory outside of the the string +allocated for parent, tail needs to stop when it +reaches or passes parent, even if it doesn't +actually equal parent. + +Signed-off-by: Frank Sorenson +--- + CHANGELOG | 1 + + lib/cache.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -86,6 +86,7 @@ + - fix root offset error handling. + - fix nonstrict fail handling of last offset mount. + - dont fail on duplicate offset entry tree add. ++- fix loop under run in cache_get_offset_parent(). + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/cache.c ++++ autofs-5.1.4/lib/cache.c +@@ -680,7 +680,7 @@ struct mapent *cache_get_offset_parent(s + *tail = 0; + + tail--; +- if (tail == parent) ++ if (tail <= parent) + break; + + me = cache_lookup_distinct(mc, parent); diff --git a/SOURCES/autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch b/SOURCES/autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch new file mode 100644 index 0000000..750cc33 --- /dev/null +++ b/SOURCES/autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch @@ -0,0 +1,40 @@ +autofs-5.1.8 - fix memory leak in xdr_exports() + +From: Ian Kent + +Converting xdr_exports() to not be recursive introduced a memory leak +if an error is encountered, fix it. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/rpc_subs.c | 7 ++++++- + 2 files changed, 7 insertions(+), 1 deletion(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -89,6 +89,7 @@ + - fix loop under run in cache_get_offset_parent(). + - simplify cache_add() a little. + - fix use after free in tree_mapent_delete_offset_tree(). ++- fix memory leak in xdr_exports(). + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/rpc_subs.c ++++ autofs-5.1.4/lib/rpc_subs.c +@@ -1151,8 +1151,13 @@ bool_t xdr_exports(XDR *xdrs, struct exp + + export = (char **) exports; + while (1) { +- if (!xdr_pointer(xdrs, export, size, (xdrproc_t) xdr_export)) ++ if (!xdr_pointer(xdrs, export, size, (xdrproc_t) xdr_export)) { ++ if (*exports) { ++ rpc_exports_free(*exports); ++ *exports = NULL; ++ } + return FALSE; ++ } + if (!*export) + break; + export = (char **) &((struct exportinfo *) *export)->next; diff --git a/SOURCES/autofs-5.1.8-fix-nonstrict-fail-handling-of-last-offset-mount.patch b/SOURCES/autofs-5.1.8-fix-nonstrict-fail-handling-of-last-offset-mount.patch new file mode 100644 index 0000000..c9ae852 --- /dev/null +++ b/SOURCES/autofs-5.1.8-fix-nonstrict-fail-handling-of-last-offset-mount.patch @@ -0,0 +1,38 @@ +autofs-5.1.8 - fix nonstrict fail handling of last offset mount + +From: Ian Kent + +When mounting a list of multi-mount offsets the offset mount should +succeed even if there's a mount failure for the non-strict case (the +default). + +But currently if the last offset mount fails the multi-mount fails +regardless of whether the mount is non-strict or not. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -84,6 +84,7 @@ + - fix double quoting in auto.smb. + - fix double quoting of ampersand in auto.smb as well. + - fix root offset error handling. ++- fix nonstrict fail handling of last offset mount. + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/mounts.c ++++ autofs-5.1.4/lib/mounts.c +@@ -1940,7 +1940,7 @@ static int tree_mapent_mount_offsets_wor + tree_mapent_mount_offsets(oe, !ctxt->strict); + } + +- return ret; ++ return (ctxt->strict ? ret : 1); + } + + int tree_mapent_mount_offsets(struct mapent *oe, int nonstrict) diff --git a/SOURCES/autofs-5.1.8-fix-root-offset-error-handling.patch b/SOURCES/autofs-5.1.8-fix-root-offset-error-handling.patch new file mode 100644 index 0000000..482082f --- /dev/null +++ b/SOURCES/autofs-5.1.8-fix-root-offset-error-handling.patch @@ -0,0 +1,86 @@ +autofs-5.1.8 - fix root offset error handling + +From: Ian Kent + +If mounting the root or offsets of a multi-mount root fails any mounts +done so far need to be umounted and the multi-mount offset tree deleted +so it can be created cleanly and possibly mounted the next time it's +triggered. + +Also, if a subtree that is not the multi-mount root fails the expire +alarm needs to be re-instated so other subtrees (at least the root) +will continue to expire. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 11 ++++++++++- + modules/parse_sun.c | 6 ++++++ + 3 files changed, 17 insertions(+), 1 deletion(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -83,6 +83,7 @@ + - improve descriptor open error reporting. + - fix double quoting in auto.smb. + - fix double quoting of ampersand in auto.smb as well. ++- fix root offset error handling. + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/daemon/direct.c ++++ autofs-5.1.4/daemon/direct.c +@@ -1163,6 +1163,7 @@ static void *do_mount_direct(void *arg) + struct ioctl_ops *ops = get_ioctl_ops(); + struct pending_args *args, mt; + struct autofs_point *ap; ++ struct mapent *me; + struct stat st; + int status, state; + +@@ -1226,7 +1227,6 @@ static void *do_mount_direct(void *arg) + pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &state); + if (status) { + struct mnt_list *sbmnt; +- struct mapent *me; + struct statfs fs; + unsigned int close_fd = 0; + unsigned int flags = MNTS_DIRECT|MNTS_MOUNTED; +@@ -1267,6 +1267,15 @@ static void *do_mount_direct(void *arg) + mt.ioctlfd, mt.wait_queue_token, -ENOENT); + ops->close(ap->logopt, mt.ioctlfd); + info(ap->logopt, "failed to mount %s", mt.name); ++ ++ /* If this is a multi-mount subtree mount failure ++ * ensure the tree continues to expire. ++ */ ++ cache_readlock(mt.mc); ++ me = cache_lookup_distinct(mt.mc, mt.name); ++ if (me && IS_MM(me) && !IS_MM_ROOT(me)) ++ conditional_alarm_add(ap, ap->exp_runfreq); ++ cache_unlock(mt.mc); + } + pthread_setcancelstate(state, NULL); + +--- autofs-5.1.4.orig/modules/parse_sun.c ++++ autofs-5.1.4/modules/parse_sun.c +@@ -1125,6 +1125,9 @@ static int mount_subtree(struct autofs_p + if (!len) { + warn(ap->logopt, "path loo long"); + cache_unlock(mc); ++ cache_writelock(mc); ++ tree_mapent_delete_offsets(mc, name); ++ cache_unlock(mc); + return 1; + } + key[len] = '/'; +@@ -1169,6 +1172,9 @@ static int mount_subtree(struct autofs_p + cache_unlock(mc); + error(ap->logopt, MODPREFIX + "failed to mount offset triggers"); ++ cache_writelock(mc); ++ tree_mapent_delete_offsets(mc, name); ++ cache_unlock(mc); + return 1; + } + } diff --git a/SOURCES/autofs-5.1.8-fix-sysconf-return-handling.patch b/SOURCES/autofs-5.1.8-fix-sysconf-return-handling.patch new file mode 100644 index 0000000..252c3b8 --- /dev/null +++ b/SOURCES/autofs-5.1.8-fix-sysconf-return-handling.patch @@ -0,0 +1,64 @@ +autofs-5.1.8 - fix sysconf(3) return handling + +From: Fabian Groffen + +The sysconf(3) return handling doesn't handle a -1 return with errno +not changed which indicated a maximum or minimum limit that's not +known. + +Add handling of this case. + +Signed-off-by: Fabian Groffen +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 13 +++++++++++-- + 2 files changed, 12 insertions(+), 2 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -91,6 +91,7 @@ + - fix use after free in tree_mapent_delete_offset_tree(). + - fix memory leak in xdr_exports(). + - avoid calling pthread_getspecific() with NULL key_thread_attempt_id. ++- fix sysconf(3) return handling. + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/mounts.c ++++ autofs-5.1.4/lib/mounts.c +@@ -2385,11 +2385,17 @@ void set_tsd_user_vars(unsigned int logo + + /* Try to get passwd info */ + ++ /* sysconf may return -1 with unchanged errno to indicate unlimited ++ * size, same for the call for _SC_GETGR_R_SIZE_MAX below ++ */ ++ errno = 0; + tmplen = sysconf(_SC_GETPW_R_SIZE_MAX); +- if (tmplen < 0) { ++ if (tmplen < 0 && errno != 0) { + error(logopt, "failed to get buffer size for getpwuid_r"); + goto free_tsv; + } ++ if (tmplen < 0) ++ tmplen = 1024; /* assume something reasonable */ + + pw_tmp = malloc(tmplen + 1); + if (!pw_tmp) { +@@ -2422,11 +2428,14 @@ void set_tsd_user_vars(unsigned int logo + + /* Try to get group info */ + ++ errno = 0; + grplen = sysconf(_SC_GETGR_R_SIZE_MAX); +- if (grplen < 0) { ++ if (grplen < 0 && errno != 0) { + error(logopt, "failed to get buffer size for getgrgid_r"); + goto free_tsv_home; + } ++ if (grplen < 0) ++ grplen = 1024; + + gr_tmp = NULL; + status = ERANGE; diff --git a/SOURCES/autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patch b/SOURCES/autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patch new file mode 100644 index 0000000..a2f72e6 --- /dev/null +++ b/SOURCES/autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patch @@ -0,0 +1,55 @@ +autofs-5.1.8 - fix use after free in tree_mapent_delete_offset_tree() + +From: Ian Kent + +The key field of the map entry of the root of the map entry tree to be +deleted can't be used for the key parameter, fix it. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/mounts.c | 16 +++++++++++++--- + 2 files changed, 14 insertions(+), 3 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -88,6 +88,7 @@ + - dont fail on duplicate offset entry tree add. + - fix loop under run in cache_get_offset_parent(). + - simplify cache_add() a little. ++- fix use after free in tree_mapent_delete_offset_tree(). + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/mounts.c ++++ autofs-5.1.4/lib/mounts.c +@@ -1666,16 +1666,26 @@ static int tree_mapent_delete_offset_tre + */ + if (MAPENT_ROOT(me) != MAPENT_NODE(me)) { + struct tree_node *root = MAPENT_ROOT(me); ++ char *key; + +- debug(logopt, "deleting offset key %s", me->key); ++ key = strdup(me->key); ++ if (!key) { ++ char buf[MAX_ERR_BUF]; ++ char *estr = strerror_r(errno, buf, MAX_ERR_BUF); ++ error(logopt, "strdup: %s", estr); ++ return 0; ++ } ++ ++ debug(logopt, "deleting offset key %s", key); + + /* cache_delete won't delete an active offset */ + MAPENT_SET_ROOT(me, NULL); +- ret = cache_delete(me->mc, me->key); ++ ret = cache_delete(me->mc, key); + if (ret != CHE_OK) { + MAPENT_SET_ROOT(me, root); +- warn(logopt, "failed to delete offset %s", me->key); ++ warn(logopt, "failed to delete offset %s", key); + } ++ free(key); + } else { + MAPENT_SET_ROOT(me, NULL); + MAPENT_SET_PARENT(me, NULL); diff --git a/SOURCES/autofs-5.1.8-simplify-cache_add-a-little.patch b/SOURCES/autofs-5.1.8-simplify-cache_add-a-little.patch new file mode 100644 index 0000000..37726d0 --- /dev/null +++ b/SOURCES/autofs-5.1.8-simplify-cache_add-a-little.patch @@ -0,0 +1,44 @@ +autofs-5.1.8 - simplify cache_add() a little + +From: Ian Kent + +If a map entry is being added to an existing hash chain there's an +unneccessarily complicted setting of ->next of the last entry. + +Just initialize the map entry ->next field instead and remove the +confusing assignment. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + lib/cache.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -87,6 +87,7 @@ + - fix nonstrict fail handling of last offset mount. + - dont fail on duplicate offset entry tree add. + - fix loop under run in cache_get_offset_parent(). ++- simplify cache_add() a little. + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/lib/cache.c ++++ autofs-5.1.4/lib/cache.c +@@ -564,6 +564,7 @@ int cache_add(struct mapent_cache *mc, s + me->dev = (dev_t) -1; + me->ino = (ino_t) -1; + me->flags = 0; ++ me->next = NULL; + + /* + * We need to add to the end if values exist in order to +@@ -583,7 +584,6 @@ int cache_add(struct mapent_cache *mc, s + + existing = next; + } +- me->next = existing->next; + existing->next = me; + } + return CHE_OK; diff --git a/SPECS/autofs.spec b/SPECS/autofs.spec index 47b99f9..fbe0fdc 100644 --- a/SPECS/autofs.spec +++ b/SPECS/autofs.spec @@ -8,7 +8,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.1.4 -Release: 77%{?dist} +Release: 81%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -253,6 +253,16 @@ Patch226: autofs-5.1.8-improve-descriptor-open-error-reporting.patch Patch227: autofs-5.1.6-fix-double-quoting-in-auto.smb.patch Patch228: autofs-5.1.6-fix-double-quoting-of-ampersand-in-auto.smb-as-well.patch +Patch229: autofs-5.1.8-fix-root-offset-error-handling.patch +Patch230: autofs-5.1.8-fix-nonstrict-fail-handling-of-last-offset-mount.patch +Patch231: autofs-5.1.8-dont-fail-on-duplicate-host-export-entry.patch +Patch232: autofs-5.1.8-fix-loop-under-run-in-cache_get_offset_parent.patch +Patch233: autofs-5.1.8-simplify-cache_add-a-little.patch +Patch234: autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patch +Patch235: autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch +Patch236: autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch +Patch237: autofs-5.1.8-fix-sysconf-return-handling.patch + %if %{with_systemd} BuildRequires: systemd-units BuildRequires: systemd-devel @@ -547,6 +557,16 @@ echo %{version}-%{release} > .version %patch227 -p1 %patch228 -p1 +%patch229 -p1 +%patch230 -p1 +%patch231 -p1 +%patch232 -p1 +%patch233 -p1 +%patch234 -p1 +%patch235 -p1 +%patch236 -p1 +%patch237 -p1 + %build LDFLAGS=-Wl,-z,now %configure --disable-mount-locking --enable-ignore-busy --with-libtirpc --without-hesiod %{?systemd_configure_arg:} @@ -641,6 +661,19 @@ fi %dir /etc/auto.master.d %changelog +* Mon Feb 14 2022 Ian Kent - 5.1.4-81 +- bz2033552 - Using -hosts option does not work after upgrading from 8.4 to 8.5 + - fix root offset error handling. + - fix nonstrict fail handling of last offset mount. + - dont fail on duplicate offset entry tree add. + - fix loop under run in cache_get_offset_parent(). + - simplify cache_add() a little. + - fix use after free in tree_mapent_delete_offset_tree(). + - fix memory leak in xdr_exports(). + - avoid calling pthread_getspecific() with NULL key_thread_attempt_id. + - fix sysconf(3) return handling. +- Resolves: rhbz#2033552 + * Fri Dec 03 2021 Ian Kent - 5.1.4-77 - bz2025509 - Autofs auto.smb awk script fails on shares with dollar signs - fix double quoting in auto.smb.