diff --git a/autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch b/autofs-5.1.8-avoid-calling-pthread_getspecific-with-NULL-key_thread_attempt_id.patch new file mode 100644 index 0000000..2d64307 --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -92,6 +92,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. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/log.c ++++ autofs-5.1.7/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/autofs-5.1.8-dont-fail-on-duplicate-host-export-entry.patch b/autofs-5.1.8-dont-fail-on-duplicate-host-export-entry.patch new file mode 100644 index 0000000..ea7d740 --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -87,6 +87,7 @@ + - fix root offset error handling. + - fix fix root offset error handling. + - fix nonstrict fail handling of last offset mount. ++- dont fail on duplicate offset entry tree add. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/mounts.c ++++ autofs-5.1.7/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/autofs-5.1.8-fix-fix-root-offset-error-handling.patch b/autofs-5.1.8-fix-fix-root-offset-error-handling.patch new file mode 100644 index 0000000..d91a7a3 --- /dev/null +++ b/autofs-5.1.8-fix-fix-root-offset-error-handling.patch @@ -0,0 +1,34 @@ +autofs-5.1.8 - fix fix root offset error handling + +From: Ian Kent + +The change to fix root offset error handlling is missing a cache read +lock prior to the key lookup, the following unmatched unlock then +causes a hang. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/direct.c | 1 + + 2 files changed, 2 insertions(+) + +--- autofs-5.1.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -85,6 +85,7 @@ + - fix set open file limit. + - improve descriptor open error reporting. + - fix root offset error handling. ++- fix fix root offset error handling. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/daemon/direct.c ++++ autofs-5.1.7/daemon/direct.c +@@ -1271,6 +1271,7 @@ static void *do_mount_direct(void *arg) + /* 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); diff --git a/autofs-5.1.8-fix-loop-under-run-in-cache_get_offset_parent.patch b/autofs-5.1.8-fix-loop-under-run-in-cache_get_offset_parent.patch new file mode 100644 index 0000000..d29984b --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -88,6 +88,7 @@ + - fix 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(). + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/cache.c ++++ autofs-5.1.7/lib/cache.c +@@ -710,7 +710,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/autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch b/autofs-5.1.8-fix-memory-leak-in-xdr_exports.patch new file mode 100644 index 0000000..81a5e03 --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -91,6 +91,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(). + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/rpc_subs.c ++++ autofs-5.1.7/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/autofs-5.1.8-fix-nonstrict-fail-handling-of-last-offset-mount.patch b/autofs-5.1.8-fix-nonstrict-fail-handling-of-last-offset-mount.patch new file mode 100644 index 0000000..59a250e --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -86,6 +86,7 @@ + - improve descriptor open error reporting. + - fix root offset error handling. + - fix fix root offset error handling. ++- fix nonstrict fail handling of last offset mount. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/mounts.c ++++ autofs-5.1.7/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/autofs-5.1.8-fix-root-offset-error-handling.patch b/autofs-5.1.8-fix-root-offset-error-handling.patch new file mode 100644 index 0000000..30c4074 --- /dev/null +++ b/autofs-5.1.8-fix-root-offset-error-handling.patch @@ -0,0 +1,85 @@ +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 | 10 +++++++++- + modules/parse_sun.c | 6 ++++++ + 3 files changed, 16 insertions(+), 1 deletion(-) + +--- autofs-5.1.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -84,6 +84,7 @@ + - fix fedfs build flags. + - fix set open file limit. + - improve descriptor open error reporting. ++- fix root offset error handling. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/daemon/direct.c ++++ autofs-5.1.7/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,14 @@ 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. ++ */ ++ 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.7.orig/modules/parse_sun.c ++++ autofs-5.1.7/modules/parse_sun.c +@@ -1142,6 +1142,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] = '/'; +@@ -1186,6 +1189,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/autofs-5.1.8-fix-sysconf-return-handling.patch b/autofs-5.1.8-fix-sysconf-return-handling.patch new file mode 100644 index 0000000..23f09da --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -93,6 +93,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. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/mounts.c ++++ autofs-5.1.7/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/autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patch b/autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patch new file mode 100644 index 0000000..fc9b288 --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -90,6 +90,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(). + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/mounts.c ++++ autofs-5.1.7/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/autofs-5.1.8-simplify-cache_add-a-little.patch b/autofs-5.1.8-simplify-cache_add-a-little.patch new file mode 100644 index 0000000..034816d --- /dev/null +++ b/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.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -89,6 +89,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. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/lib/cache.c ++++ autofs-5.1.7/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;