diff -pruN 5.1.8-1/debian/changelog 5.1.8-1ubuntu3/debian/changelog
--- 5.1.8-1/debian/changelog	2021-12-01 22:52:49.000000000 +0000
+++ 5.1.8-1ubuntu3/debian/changelog	2022-07-28 05:27:10.000000000 +0000
@@ -1,3 +1,26 @@
+autofs (5.1.8-1ubuntu3) kinetic; urgency=medium
+
+  * d/p/autofs-5.1.8-ldap-kerberos-leads-to-automount-hang-p.patch: fix
+    lock imbalance (LP: #1982219)
+
+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com>  Thu, 28 Jul 2022 07:27:10 +0200
+
+autofs (5.1.8-1ubuntu2) kinetic; urgency=medium
+
+  * d/p/fix-nfsv4-only-mounts-should-not-use-rpcbind.patch:
+    Make NFSv4-only mounts not depend on rpcbind.  (LP: #1970264)
+
+ -- Sergio Durigan Junior <sergio.durigan@canonical.com>  Thu, 28 Apr 2022 23:05:15 -0400
+
+autofs (5.1.8-1ubuntu1) jammy; urgency=medium
+
+  * Fix authenticated cifs mount failure caught by DEP8  (LP: #1955851):
+    - d/t/smb-mount: fix setting the password of the smb test user
+    - d/p/fix-loop-under-run-in-cache_get_offset_parent.patch: fix crash
+      on s390x
+
+ -- Andreas Hasenack <andreas@canonical.com>  Thu, 20 Jan 2022 15:16:09 -0300
+
 autofs (5.1.8-1) unstable; urgency=medium
 
   * New upstream release.
diff -pruN 5.1.8-1/debian/control 5.1.8-1ubuntu3/debian/control
--- 5.1.8-1/debian/control	2021-12-01 22:52:23.000000000 +0000
+++ 5.1.8-1ubuntu3/debian/control	2022-07-28 05:21:26.000000000 +0000
@@ -1,7 +1,8 @@
 Source: autofs
 Section: utils
 Priority: optional
-Maintainer: Mike Gabriel <sunweaver@debian.org>
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Mike Gabriel <sunweaver@debian.org>
 Uploaders:
  Debian Edu Packaging Team <debian-edu-pkg-team@lists.alioth.debian.org>,
 Build-Depends:
diff -pruN 5.1.8-1/debian/patches/autofs-5.1.8-ldap-kerberos-leads-to-automount-hang-p.patch 5.1.8-1ubuntu3/debian/patches/autofs-5.1.8-ldap-kerberos-leads-to-automount-hang-p.patch
--- 5.1.8-1/debian/patches/autofs-5.1.8-ldap-kerberos-leads-to-automount-hang-p.patch	1970-01-01 00:00:00.000000000 +0000
+++ 5.1.8-1ubuntu3/debian/patches/autofs-5.1.8-ldap-kerberos-leads-to-automount-hang-p.patch	2022-07-28 05:27:10.000000000 +0000
@@ -0,0 +1,45 @@
+From bd89efdee6c806190a0e78006cdc32d521dfd746 Mon Sep 17 00:00:00 2001
+From: James Dingwall <james-autofs () dingwall ! me ! uk>
+Date: Tue, 19 Jul 2022 19:55:40 +0000
+Subject: [PATCH] autofs 5.1.8: ldap+kerberos leads to automount hang [patch]
+
+Hi,
+
+Cross reference: https://bugs.launchpad.net/ubuntu/+source/autofs/+bug/1982219
+
+I recently upgraded an Ubuntu system from 20.04 to 22.04 at which point
+autofs stopped working.  `automount -d -m -v -f` would hang without
+printing the maps.  After adding some debug statements I traced this to
+an unbalanced pthread_mutex_lock()/unlock() in sasl_do_kinit_ext_cc() of
+modules/cyrus-sasl.c.  The patch attached this email resolved the problem
+for me.
+
+Thanks,
+James
+
+Origin: upstream, https://marc.info/?l=autofs&m=165826158526742&w=2
+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1982219
+Applied-Upstream: scheduled for anytihng >5.1.8
+Last-Update: 2022-07-28
+
+---
+ modules/cyrus-sasl.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/modules/cyrus-sasl.c b/modules/cyrus-sasl.c
+index ae046e01..c0b47439 100644
+--- a/modules/cyrus-sasl.c
++++ b/modules/cyrus-sasl.c
+@@ -721,6 +721,9 @@ sasl_do_kinit_ext_cc(unsigned logopt, struct lookup_context *ctxt)
+ 
+ 	debug(logopt, "Kerberos authentication was successful!");
+ 
++	status = pthread_mutex_unlock(&krb5cc_mutex);
++	if (status)
++		fatal(status);
+ 	return 0;
+ 
+ out_cleanup_def_princ:
+-- 
+2.37.1
+
diff -pruN 5.1.8-1/debian/patches/fix-loop-under-run-in-cache_get_offset_parent.patch 5.1.8-1ubuntu3/debian/patches/fix-loop-under-run-in-cache_get_offset_parent.patch
--- 5.1.8-1/debian/patches/fix-loop-under-run-in-cache_get_offset_parent.patch	1970-01-01 00:00:00.000000000 +0000
+++ 5.1.8-1ubuntu3/debian/patches/fix-loop-under-run-in-cache_get_offset_parent.patch	2022-07-28 05:21:26.000000000 +0000
@@ -0,0 +1,30 @@
+Subject: [PATCH 08/19] autofs-5.1.8 - fix loop under run in
+ cache_get_offset_parent()
+From:   Ian Kent <raven@themaw.net>
+From: Frank Sorenson <sorenson@redhat.com>
+
+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 <sorenson@redhat.com>
+---
+ lib/cache.c |    2 +-
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+Origin: upstream, https://www.spinics.net/lists/autofs/msg02432.html
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/autofs/+bug/1955851
+Last-Update: 2022-01-20
+Backport note: dropped the CHANGELOG patch hunk
+--- a/lib/cache.c
++++ b/lib/cache.c
+@@ -710,7 +710,7 @@
+ 		*tail = 0;
+ 
+ 		tail--;
+-		if (tail == parent)
++		if (tail <= parent)
+ 			break;
+ 
+ 		me = cache_lookup_distinct(mc, parent);
diff -pruN 5.1.8-1/debian/patches/fix-nfsv4-only-mounts-should-not-use-rpcbind.patch 5.1.8-1ubuntu3/debian/patches/fix-nfsv4-only-mounts-should-not-use-rpcbind.patch
--- 5.1.8-1/debian/patches/fix-nfsv4-only-mounts-should-not-use-rpcbind.patch	1970-01-01 00:00:00.000000000 +0000
+++ 5.1.8-1ubuntu3/debian/patches/fix-nfsv4-only-mounts-should-not-use-rpcbind.patch	2022-07-28 05:21:26.000000000 +0000
@@ -0,0 +1,91 @@
+From: Ian Kent <raven@themaw.net>
+Date: Thu, 28 Apr 2022 17:18:50 -0400
+Subject: fix nfsv4 only mounts should not use rpcbind
+
+Commit 606795ecfaa1 ("autofs-5.1.7 - also require TCP_REQUESTED when
+setting NFS port" together with commit 26fb6b5408be) caused NFSv4 only
+mounts to also use rpcbind to probe availability which breaks the
+requirememt that this type of mount not use rpcbind at all.
+
+Fix this by treating fstype=nfs4 mounts as a special case which doesn't
+use rpcbind.
+
+Forwarded: yes, https://www.spinics.net/lists/autofs/msg02391.html
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/autofs/+bug/1970264
+Reviewed-By: Sergio Durigan Junior <sergiodj@ubuntu.com>
+---
+ include/replicated.h |  2 ++
+ modules/mount_nfs.c  | 13 +++++++------
+ modules/replicated.c |  4 ++--
+ 3 files changed, 11 insertions(+), 8 deletions(-)
+
+diff --git a/include/replicated.h b/include/replicated.h
+index 95ff1f0..f889a56 100644
+--- a/include/replicated.h
++++ b/include/replicated.h
+@@ -35,6 +35,8 @@
+ #define NFS3_REQUESTED		NFS3_SUPPORTED
+ #define NFS4_REQUESTED		NFS4_SUPPORTED
+ 
++#define NFS4_ONLY_REQUESTED	0x0800
++
+ #define TCP_SUPPORTED		0x0001
+ #define UDP_SUPPORTED		0x0002
+ #define TCP_REQUESTED		TCP_SUPPORTED
+diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
+index 2e25af8..e807a5e 100644
+--- a/modules/mount_nfs.c
++++ b/modules/mount_nfs.c
+@@ -92,7 +92,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
+ 	mount_default_proto = defaults_get_mount_nfs_default_proto();
+ 	vers = NFS_VERS_DEFAULT | NFS_PROTO_DEFAULT;
+ 	if (strcmp(fstype, "nfs4") == 0)
+-		vers = NFS4_VERS_DEFAULT | TCP_SUPPORTED;
++		vers = NFS4_VERS_DEFAULT | TCP_SUPPORTED | NFS4_ONLY_REQUESTED;
+ 	else if (mount_default_proto == 4)
+ 		vers = vers | NFS4_VERS_DEFAULT;
+ 
+@@ -157,15 +157,16 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
+ 			} else {
+ 				/* Is any version of NFSv4 in the options */
+ 				if (_strncmp("vers=4", cp, 6) == 0 ||
+-				    _strncmp("nfsvers=4", cp, 9) == 0)
+-					vers = NFS4_VERS_MASK | TCP_SUPPORTED;
+-				else if (_strncmp("vers=3", cp, o_len) == 0 ||
++				    _strncmp("nfsvers=4", cp, 9) == 0) {
++					vers &= ~(NFS_VERS_MASK);
++					vers |= NFS4_VERS_MASK | TCP_SUPPORTED | NFS4_ONLY_REQUESTED;
++				} else if (_strncmp("vers=3", cp, o_len) == 0 ||
+ 					 _strncmp("nfsvers=3", cp, o_len) == 0) {
+-					vers &= ~(NFS4_VERS_MASK | NFS_VERS_MASK);
++					vers &= ~(NFS4_VERS_MASK | NFS_VERS_MASK | NFS4_ONLY_REQUESTED);
+ 					vers |= NFS3_REQUESTED;
+ 				} else if (_strncmp("vers=2", cp, o_len) == 0 ||
+ 					 _strncmp("nfsvers=2", cp, o_len) == 0) {
+-					vers &= ~(NFS4_VERS_MASK | NFS_VERS_MASK);
++					vers &= ~(NFS4_VERS_MASK | NFS_VERS_MASK | NFS4_ONLY_REQUESTED);
+ 					vers |= NFS2_REQUESTED;
+ 				} else if (strstr(cp, "port=") == cp &&
+ 					 o_len - 5 < 25) {
+diff --git a/modules/replicated.c b/modules/replicated.c
+index e2ec770..fc5bd50 100644
+--- a/modules/replicated.c
++++ b/modules/replicated.c
+@@ -291,7 +291,7 @@ static unsigned int get_nfs_info(unsigned logopt, struct host *host,
+ 
+ 	rpc_info->proto = proto;
+ 	if (port < 0) {
+-		if ((version & NFS4_REQUESTED) && (version & TCP_REQUESTED))
++		if (version & NFS4_REQUESTED && (version & NFS4_ONLY_REQUESTED))
+ 			rpc_info->port = NFS_PORT;
+ 		else
+ 			port = 0;
+@@ -525,7 +525,7 @@ static int get_vers_and_cost(unsigned logopt, struct host *host,
+ {
+ 	struct conn_info pm_info, rpc_info;
+ 	time_t timeout = RPC_TIMEOUT;
+-	unsigned int supported, vers = (NFS_VERS_MASK | NFS4_VERS_MASK);
++	unsigned int supported, vers = (NFS_VERS_MASK | NFS4_VERS_MASK | NFS4_ONLY_REQUESTED);
+ 	int ret = 0;
+ 
+ 	if (!check_address_proto(logopt, host, version))
diff -pruN 5.1.8-1/debian/patches/series 5.1.8-1ubuntu3/debian/patches/series
--- 5.1.8-1/debian/patches/series	2021-02-04 12:13:20.000000000 +0000
+++ 5.1.8-1ubuntu3/debian/patches/series	2022-07-28 05:27:10.000000000 +0000
@@ -9,3 +9,6 @@ hardening-flags.patch
 spelling-error-fixes.patch
 fix-lookup-ldap-crash.patch
 fix-nfs4-mounts-in-auto-net.patch
+fix-loop-under-run-in-cache_get_offset_parent.patch
+fix-nfsv4-only-mounts-should-not-use-rpcbind.patch
+autofs-5.1.8-ldap-kerberos-leads-to-automount-hang-p.patch
diff -pruN 5.1.8-1/debian/tests/smb-mount 5.1.8-1ubuntu3/debian/tests/smb-mount
--- 5.1.8-1/debian/tests/smb-mount	2019-03-31 14:44:14.000000000 +0000
+++ 5.1.8-1ubuntu3/debian/tests/smb-mount	2022-07-28 05:21:26.000000000 +0000
@@ -35,7 +35,7 @@ create_user() {
 
     useradd -m "$username"
     echo "Setting samba password for the ${username} user"
-    echo "${password}\n${password}" | smbpasswd -s -a ${username}
+    (echo "${password}"; echo "${password}") | smbpasswd -s -a ${username}
 }
 
 
