Blame SOURCES/nfs-utils-2.3.3-gssd-mutex-refcnt.patch

4cb8ad
diff -up nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig nfs-utils-2.3.3/utils/gssd/krb5_util.c
4cb8ad
--- nfs-utils-2.3.3/utils/gssd/krb5_util.c.orig	2021-07-22 15:27:27.728680553 -0400
4cb8ad
+++ nfs-utils-2.3.3/utils/gssd/krb5_util.c	2021-07-22 15:30:08.916979585 -0400
4cb8ad
@@ -165,18 +165,28 @@ static int gssd_get_single_krb5_cred(krb
4cb8ad
 static int query_krb5_ccache(const char* cred_cache, char **ret_princname,
4cb8ad
 		char **ret_realm);
4cb8ad
 
4cb8ad
-static void release_ple(krb5_context context, struct gssd_k5_kt_princ *ple)
4cb8ad
+static void release_ple_locked(krb5_context context,
4cb8ad
+			       struct gssd_k5_kt_princ *ple)
4cb8ad
 {
4cb8ad
 	if (--ple->refcount)
4cb8ad
 		return;
4cb8ad
 
4cb8ad
-	printerr(3, "freeing cached principal (ccname=%s, realm=%s)\n", ple->ccname, ple->realm);
4cb8ad
+	printerr(3, "freeing cached principal (ccname=%s, realm=%s)\n",
4cb8ad
+		 ple->ccname, ple->realm);
4cb8ad
 	krb5_free_principal(context, ple->princ);
4cb8ad
 	free(ple->ccname);
4cb8ad
 	free(ple->realm);
4cb8ad
 	free(ple);
4cb8ad
 }
4cb8ad
 
4cb8ad
+static void release_ple(krb5_context context, struct gssd_k5_kt_princ *ple)
4cb8ad
+{
4cb8ad
+	pthread_mutex_lock(&ple_lock);
4cb8ad
+	release_ple_locked(context, ple);
4cb8ad
+	pthread_mutex_unlock(&ple_lock);
4cb8ad
+}
4cb8ad
+
4cb8ad
+
4cb8ad
 /*
4cb8ad
  * Called from the scandir function to weed out potential krb5
4cb8ad
  * credentials cache files
4cb8ad
@@ -1396,7 +1406,7 @@ gssd_destroy_krb5_principals(int destroy
4cb8ad
 			}
4cb8ad
 		}
4cb8ad
 
4cb8ad
-		release_ple(context, ple);
4cb8ad
+		release_ple_locked(context, ple);
4cb8ad
 	}
4cb8ad
 	pthread_mutex_unlock(&ple_lock);
4cb8ad
 	krb5_free_context(context);