From 66f19c324d8eb48e34e9c1b5f2994b2a098e183e Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Wed, 23 Feb 2022 14:19:50 +0000 Subject: [PATCH] import autofs-5.1.4-82.el8 --- ...e-umount_ent-recognise-forced-umount.patch | 41 +++++++ ...-of-incorrect-return-from-umount_ent.patch | 110 ++++++++++++++++++ ...eter-from-tree_mapent_umount_offsets.patch | 77 ++++++++++++ SPECS/autofs.spec | 15 ++- 4 files changed, 242 insertions(+), 1 deletion(-) create mode 100644 SOURCES/autofs-5.1.4-make-umount_ent-recognise-forced-umount.patch create mode 100644 SOURCES/autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch create mode 100644 SOURCES/autofs-5.1.8-remove-nonstrict-parameter-from-tree_mapent_umount_offsets.patch diff --git a/SOURCES/autofs-5.1.4-make-umount_ent-recognise-forced-umount.patch b/SOURCES/autofs-5.1.4-make-umount_ent-recognise-forced-umount.patch new file mode 100644 index 0000000..5a3a069 --- /dev/null +++ b/SOURCES/autofs-5.1.4-make-umount_ent-recognise-forced-umount.patch @@ -0,0 +1,41 @@ +autofs-5.1.4 - make umount_ent() recognise forced umount + +From: Ian Kent + +When doing a forced shutdown umount_ent() tries a normal expire +first resulting in a fair amount of unnecessary log noise. + +Change umount_ent() to do a forced expire when a forced shutdown +has been requested to avoid the log noise. + +Signed-off-by: Ian Kent +--- + lib/mounts.c | 16 +++++++++------- + 1 file changed, 9 insertions(+), 7 deletions(-) + +--- autofs-5.1.4.orig/lib/mounts.c ++++ autofs-5.1.4/lib/mounts.c +@@ -2984,14 +2984,16 @@ int umount_ent(struct autofs_point *ap, + { + int rv; + +- rv = spawn_umount(ap->logopt, path, NULL); +- /* We are doing a forced shutcwdown down so unlink busy mounts */ +- if (rv && (ap->state == ST_SHUTDOWN_FORCE || ap->state == ST_SHUTDOWN)) { +- if (ap->state == ST_SHUTDOWN_FORCE) { +- info(ap->logopt, "forcing umount of %s", path); +- rv = spawn_umount(ap->logopt, "-l", path, NULL); +- } ++ if (ap->state != ST_SHUTDOWN_FORCE) ++ rv = spawn_umount(ap->logopt, path, NULL); ++ else { ++ /* We are doing a forced shutdown so unlink busy ++ * mounts */ ++ info(ap->logopt, "forcing umount of %s", path); ++ rv = spawn_umount(ap->logopt, "-l", path, NULL); ++ } + ++ if (rv && (ap->state == ST_SHUTDOWN_FORCE || ap->state == ST_SHUTDOWN)) { + /* + * Verify that we actually unmounted the thing. This is a + * belt and suspenders approach to not eating user data. diff --git a/SOURCES/autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch b/SOURCES/autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch new file mode 100644 index 0000000..ef5a07d --- /dev/null +++ b/SOURCES/autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch @@ -0,0 +1,110 @@ +autofs-5.1.8 - fix handling of incorrect return from umount_ent() + +From: Ian Kent + +Commit 0210535df4b ("autofs-5.1.0 - gaurd against incorrect umount +return") guards against umount_ent() returning a fail when the mount +has actually been umounted. + +But we also see umount_ent() return success when in fact the mount has +not been umounted leading to incorrect handling of automounts. + +So checking the return of umount_ent() isn't always giving the correct +result in more than just one case, consequently we should ignore the +result from the spawned umount(8) and check if the mount has in fact +been umounted. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 3 +-- + lib/mounts.c | 19 ++++++++++--------- + 3 files changed, 12 insertions(+), 11 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -93,6 +93,7 @@ + - avoid calling pthread_getspecific() with NULL key_thread_attempt_id. + - fix sysconf(3) return handling. + - remove nonstrict parameter from tree_mapent_umount_offsets(). ++- fix handling of incorrect return from umount_ent(). + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/daemon/automount.c ++++ autofs-5.1.4/daemon/automount.c +@@ -606,8 +606,7 @@ static int umount_subtree_mounts(struct + struct mnt_list *mnt; + + debug(ap->logopt, "unmounting dir = %s", path); +- if (umount_ent(ap, path) && +- is_mounted(path, MNTS_REAL)) { ++ if (umount_ent(ap, path)) { + warn(ap->logopt, "could not umount dir %s", path); + left++; + goto done; +--- autofs-5.1.4.orig/lib/mounts.c ++++ autofs-5.1.4/lib/mounts.c +@@ -1869,8 +1869,7 @@ static int tree_mapent_umount_offset(str + */ + if (oe->ioctlfd != -1 || + is_mounted(oe->key, MNTS_REAL)) { +- if (umount_ent(ap, oe->key) && +- is_mounted(oe->key, MNTS_REAL)) { ++ if (umount_ent(ap, oe->key)) { + debug(ap->logopt, + "offset %s has active mount, invalidate", + oe->key); +@@ -2010,8 +2009,7 @@ int tree_mapent_umount_offsets(struct ma + */ + if (is_mounted(mp, MNTS_REAL)) { + info(ap->logopt, "unmounting dir = %s", mp); +- if (umount_ent(ap, mp) && +- is_mounted(mp, MNTS_REAL)) { ++ if (umount_ent(ap, mp)) { + if (!tree_mapent_mount_offsets(oe, 1)) + warn(ap->logopt, + "failed to remount offset triggers"); +@@ -2982,6 +2980,7 @@ void set_direct_mount_tree_catatonic(str + + int umount_ent(struct autofs_point *ap, const char *path) + { ++ unsigned int mounted; + int rv; + + if (ap->state != ST_SHUTDOWN_FORCE) +@@ -2993,6 +2992,8 @@ int umount_ent(struct autofs_point *ap, + rv = spawn_umount(ap->logopt, "-l", path, NULL); + } + ++ mounted = is_mounted(path, MNTS_REAL); ++ + if (rv && (ap->state == ST_SHUTDOWN_FORCE || ap->state == ST_SHUTDOWN)) { + /* + * Verify that we actually unmounted the thing. This is a +@@ -3004,20 +3005,20 @@ int umount_ent(struct autofs_point *ap, + * so that we do not try to call rmdir_path on the + * directory. + */ +- if (is_mounted(path, MNTS_REAL)) { ++ if (mounted) { + crit(ap->logopt, + "the umount binary reported that %s was " + "unmounted, but there is still something " + "mounted on this path.", path); +- rv = -1; ++ mounted = -1; + } + } + +- /* On success, check for mounted mount and remove it if found */ +- if (!rv) ++ /* If mount is gone remove it from mounted mounts list. */ ++ if (!mounted) + mnts_remove_mount(path, MNTS_MOUNTED); + +- return rv; ++ return mounted; + } + + int umount_amd_ext_mount(struct autofs_point *ap, const char *path) diff --git a/SOURCES/autofs-5.1.8-remove-nonstrict-parameter-from-tree_mapent_umount_offsets.patch b/SOURCES/autofs-5.1.8-remove-nonstrict-parameter-from-tree_mapent_umount_offsets.patch new file mode 100644 index 0000000..88e98b4 --- /dev/null +++ b/SOURCES/autofs-5.1.8-remove-nonstrict-parameter-from-tree_mapent_umount_offsets.patch @@ -0,0 +1,77 @@ +autofs-5.1.8 - remove nonstrict parameter from tree_mapent_umount_offsets() + +From: Ian Kent + +The nonstrict parameter of tree_mapent_umount_offsets() ins't useful +because if a real mount at the base of a sub-tree fails to umount all +we can do is re-instate the offset mounts under it which must succeed +for the mount tree to remain useful. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/automount.c | 2 +- + include/mounts.h | 2 +- + lib/mounts.c | 6 +++--- + 4 files changed, 6 insertions(+), 5 deletions(-) + +--- autofs-5.1.4.orig/CHANGELOG ++++ autofs-5.1.4/CHANGELOG +@@ -92,6 +92,7 @@ + - fix memory leak in xdr_exports(). + - avoid calling pthread_getspecific() with NULL key_thread_attempt_id. + - fix sysconf(3) return handling. ++- remove nonstrict parameter from tree_mapent_umount_offsets(). + + xx/xx/2018 autofs-5.1.5 + - fix flag file permission. +--- autofs-5.1.4.orig/daemon/automount.c ++++ autofs-5.1.4/daemon/automount.c +@@ -555,7 +555,7 @@ static int umount_subtree_mounts(struct + struct mapent *tmp; + int ret; + +- ret = tree_mapent_umount_offsets(me, 1); ++ ret = tree_mapent_umount_offsets(me); + if (!ret) { + warn(ap->logopt, + "some offset mounts still present under %s", path); +--- autofs-5.1.4.orig/include/mounts.h ++++ autofs-5.1.4/include/mounts.h +@@ -182,7 +182,7 @@ int tree_mapent_add_node(struct mapent_c + int tree_mapent_delete_offsets(struct mapent_cache *mc, const char *key); + void tree_mapent_cleanup_offsets(struct mapent *oe); + int tree_mapent_mount_offsets(struct mapent *oe, int nonstrict); +-int tree_mapent_umount_offsets(struct mapent *oe, int nonstrict); ++int tree_mapent_umount_offsets(struct mapent *oe); + int unlink_mount_tree(struct autofs_point *ap, const char *mp); + void free_mnt_list(struct mnt_list *list); + int is_mounted(const char *mp, unsigned int type); +--- autofs-5.1.4.orig/lib/mounts.c ++++ autofs-5.1.4/lib/mounts.c +@@ -1843,7 +1843,7 @@ static int tree_mapent_umount_offset(str + * Check for and umount subtree offsets resulting from + * nonstrict mount fail. + */ +- ret = tree_mapent_umount_offsets(oe, ctxt->strict); ++ ret = tree_mapent_umount_offsets(oe); + if (!ret) + return 0; + +@@ -1975,14 +1975,14 @@ static int tree_mapent_umount_offsets_wo + return tree_mapent_umount_offset(oe, ptr); + } + +-int tree_mapent_umount_offsets(struct mapent *oe, int nonstrict) ++int tree_mapent_umount_offsets(struct mapent *oe) + { + struct tree_node *base = MAPENT_NODE(oe); + struct autofs_point *ap = oe->mc->ap; + struct traverse_subtree_context ctxt = { + .ap = ap, + .base = base, +- .strict = !nonstrict, ++ .strict = 1, + }; + int ret; + diff --git a/SPECS/autofs.spec b/SPECS/autofs.spec index fbe0fdc..06ff758 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: 81%{?dist} +Release: 82%{?dist} Epoch: 1 License: GPLv2+ Group: System Environment/Daemons @@ -262,6 +262,9 @@ Patch234: autofs-5.1.8-fix-use-after-free-in-tree_mapent_delete_offset_tree.patc 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 +Patch238: autofs-5.1.4-make-umount_ent-recognise-forced-umount.patch +Patch239: autofs-5.1.8-remove-nonstrict-parameter-from-tree_mapent_umount_offsets.patch +Patch240: autofs-5.1.8-fix-handling-of-incorrect-return-from-umount_ent.patch %if %{with_systemd} BuildRequires: systemd-units @@ -566,6 +569,9 @@ echo %{version}-%{release} > .version %patch235 -p1 %patch236 -p1 %patch237 -p1 +%patch238 -p1 +%patch239 -p1 +%patch240 -p1 %build LDFLAGS=-Wl,-z,now @@ -661,6 +667,13 @@ fi %dir /etc/auto.master.d %changelog +* Tue Feb 15 2022 Ian Kent - 5.1.4-82 +- bz2052122 - autofs attempts unmount on directory in use + - make umount_ent() recognise forced umount. + - remove nonstrict parameter from tree_mapent_umount_offsets(). + - fix handling of incorrect return from umount_ent(). +- Resolves: rhbz#2052122 + * 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.