From 149ba188395d8ee998dc6269a7811eab4b152186 Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Tue, 6 Jun 2023 08:51:40 +0800 Subject: [PATCH] - add changes to resolve bug bz2210161. --- ...fix-fix-mount-tree-startup-reconnect.patch | 45 +++++++++++++++++++ ...1.8-fix-memory-leak-in-sasl_do_kinit.patch | 45 +++++++++++++++++++ autofs.spec | 15 ++++++- 3 files changed, 104 insertions(+), 1 deletion(-) create mode 100644 autofs-5.1.8-fix-fix-mount-tree-startup-reconnect.patch create mode 100644 autofs-5.1.8-fix-memory-leak-in-sasl_do_kinit.patch diff --git a/autofs-5.1.8-fix-fix-mount-tree-startup-reconnect.patch b/autofs-5.1.8-fix-fix-mount-tree-startup-reconnect.patch new file mode 100644 index 0000000..f157885 --- /dev/null +++ b/autofs-5.1.8-fix-fix-mount-tree-startup-reconnect.patch @@ -0,0 +1,45 @@ +autofs-5.1.8 - fix fix mount tree startup reconnect + +From: Ian Kent + +In function master_mount_mounts() commit 635b90eccee9 checks if the +current top level mount is already running by using two things, if the +mount handling thread id is set in the autofs mount point structure and +if the mount point path is a mounted autofs file system. + +But the top level master map entry for a direct mount map is the +reserved path "/-" and doesn't have an actual mount associated with it +so a mounted check can't be used. But we know that top level mounts +start in state ST_INIT and once that state is changed it never changes +back to it. So using the presence of the mount handling thread id and +the state not being ST_INIT is sufficient to know if this is a new +mount or not. + +Fixes: 635b90eccee9 ("autofs-5.1.8 - fix mount tree startup reconnect") +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + daemon/master.c | 2 +- + 2 files changed, 2 insertions(+), 1 deletion(-) + +--- autofs-5.1.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -132,6 +132,7 @@ + - fix mount tree startup reconnect. + - fix unterminated read in handle_cmd_pipe_fifo_message(). + - fix memory leak in sasl_do_kinit() ++- fix fix mount tree startup reconnect. + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/daemon/master.c ++++ autofs-5.1.7/daemon/master.c +@@ -1553,7 +1553,7 @@ int master_mount_mounts(struct master *m + } + cache_unlock(nc); + cont: +- if (ap->thid && is_mounted(this->path, MNTS_AUTOFS)) ++ if (ap->thid && ap->state != ST_INIT) + check_update_map_sources(this, master->readall); + else { + if (!master_do_mount(this)) { diff --git a/autofs-5.1.8-fix-memory-leak-in-sasl_do_kinit.patch b/autofs-5.1.8-fix-memory-leak-in-sasl_do_kinit.patch new file mode 100644 index 0000000..134b667 --- /dev/null +++ b/autofs-5.1.8-fix-memory-leak-in-sasl_do_kinit.patch @@ -0,0 +1,45 @@ +autofs-5.1.8 - fix memory leak in sasl_do_kinit() + +From: Ian Kent + +In sasl_do_kinit() there is a failure case that omits freeing the local +variable tgs_princ, fix it. + +Signed-off-by: Ian Kent +--- + CHANGELOG | 1 + + modules/cyrus-sasl.c | 5 +++-- + 2 files changed, 4 insertions(+), 2 deletions(-) + +--- autofs-5.1.7.orig/CHANGELOG ++++ autofs-5.1.7/CHANGELOG +@@ -131,6 +131,7 @@ + - get rid of unused field submnt_count. + - fix mount tree startup reconnect. + - fix unterminated read in handle_cmd_pipe_fifo_message(). ++- fix memory leak in sasl_do_kinit() + + 25/01/2021 autofs-5.1.7 + - make bind mounts propagation slave by default. +--- autofs-5.1.7.orig/modules/cyrus-sasl.c ++++ autofs-5.1.7/modules/cyrus-sasl.c +@@ -503,7 +503,7 @@ sasl_do_kinit(unsigned logopt, struct lo + if (ret) { + error(logopt, "krb5_unparse_name failed with error %d", + ret); +- goto out_cleanup_client_princ; ++ goto out_cleanup_tgs_princ; + } + + debug(logopt, "Using tgs name %s", tgs_name); +@@ -565,8 +565,9 @@ out_cleanup_creds: + krb5cc_in_use--; + krb5_free_cred_contents(ctxt->krb5ctxt, &my_creds); + out_cleanup_unparse: +- krb5_free_principal(ctxt->krb5ctxt, tgs_princ); + krb5_free_unparsed_name(ctxt->krb5ctxt, tgs_name); ++out_cleanup_tgs_princ: ++ krb5_free_principal(ctxt->krb5ctxt, tgs_princ); + out_cleanup_client_princ: + krb5_free_principal(ctxt->krb5ctxt, krb5_client_princ); + out_cleanup_cc: diff --git a/autofs.spec b/autofs.spec index e6e1b8b..a2eda8b 100644 --- a/autofs.spec +++ b/autofs.spec @@ -12,7 +12,7 @@ Summary: A tool for automatically mounting and unmounting filesystems Name: autofs Version: 5.1.7 -Release: 50%{?dist} +Release: 51%{?dist} Epoch: 1 License: GPLv2+ Source: https://www.kernel.org/pub/linux/daemons/autofs/v5/autofs-%{version}-2.tar.gz @@ -159,6 +159,9 @@ Patch133: autofs-5.1.8-get-rid-of-unused-field-submnt_count.patch Patch134: autofs-5.1.8-fix-mount-tree-startup-reconnect.patch Patch135: autofs-5.1.8-fix-unterminated-read-in-handle_cmd_pipe_fifo_message.patch +Patch150: autofs-5.1.8-fix-memory-leak-in-sasl_do_kinit.patch +Patch151: autofs-5.1.8-fix-fix-mount-tree-startup-reconnect.patch + %if %{with_systemd} BuildRequires: systemd-units BuildRequires: systemd-devel @@ -361,6 +364,9 @@ echo %{version}-%{release} > .version %patch134 -p1 %patch135 -p1 +%patch150 -p1 +%patch151 -p1 + %build LDFLAGS=-Wl,-z,now %configure \ @@ -468,6 +474,13 @@ fi %dir /etc/auto.master.d %changelog +* Fri Jun 02 2023 Ian Kent - 1:5.1.7-51 +- bz2210161 - autofs fails to start with combination of +auto.master and + local direct map lookups after upgrading to 5.1.4-93.el8 + - fix memory leak in sasl_do_kinit() (Coverity). + - fix fix mount tree startup reconnect. +- Resolves: rhbz#2210161 + * Tue Mar 28 2023 Ian Kent - 1:5.1.7-50 - bz2179753 - deadlock while reading amd maps - fix return status of mount_autofs().