Skip to contentSkip to conversation

adding pthread support to gssd

RFC PATCH Superseded Olga Kornievskaia 4 participants 10 messages Apr 25, 2016 – Apr 27, 2016 2 messages not in the archive

Subsystems (2)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover adding pthread support to gssd

Adding support for multi-threaded gssd and allow for parallel upcalls. For each upcall create a thread, detach to allow for automatic cleanup. Communicate location of credential cache with gss api function instead of an environmental variable. Use syscall api instead of libc setuid() to change user identity.

Previously parent thread after detaching from child thread would call yield to let the child thread run and consume the event from the fd. Instead, use synchronization variables to signal parent after reading from fd and have parent thread wait for the event.

Olga Kornievskaia (3):
gssd: use pthreads to handle upcalls
gssd: using syscalls directly to change thread's identity
gssd: always call gss_krb5_ccache_name

 aclocal/libpthread.m4  | 13 ++++++++++
 configure.ac           |  3 +++
 utils/gssd/Makefile.am |  3 ++-
 utils/gssd/gssd.c      | 44 ++++++++++++++++++++++++++++++---
 utils/gssd/gssd.h      |  5 ++++
 utils/gssd/gssd_proc.c | 66 +++++++++++++++++++++++---------------------------
 utils/gssd/krb5_util.c | 59 ++++++++++----------------------------------
 utils/gssd/krb5_util.h |  1 -
 8 files changed, 106 insertions(+), 88 deletions(-)
 create mode 100644 aclocal/libpthread.m4
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v3 1/3 gssd: use pthreads to handle upcalls

Currently, to persevere global data over multiple mounts, the root process does not fork when handling an upcall. Instead on not-forking create a pthread to handle the upcall since global data can be shared among threads.

---
 aclocal/libpthread.m4  | 13 +++++++++++++
 configure.ac           |  3 +++
 utils/gssd/Makefile.am |  3 ++-
 utils/gssd/gssd.c      | 45 ++++++++++++++++++++++++++++++++++++++++-----
 utils/gssd/gssd.h      |  5 +++++
 utils/gssd/gssd_proc.c | 49 ++++++++++++++++++-------------------------------
 utils/gssd/krb5_util.c |  3 +++
 7 files changed, 84 insertions(+), 37 deletions(-)
 create mode 100644 aclocal/libpthread.m4
aclocal/libpthread.m4 new file +13 -0
new file mode 100644
index 0000000..e87d2a0
@@ -0,0 +1,13 @@
+dnl Checks for pthreads library and headers
+dnl
+AC_DEFUN([AC_LIBPTHREAD], [
+
+    dnl Check for library, but do not add -lpthreads to LIBS
+    AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD=-lpthread],
+                 [AC_MSG_ERROR([libpthread not found.])])
+  AC_SUBST(LIBPTHREAD)
+
+  AC_CHECK_HEADERS([pthread.h], ,
+                   [AC_MSG_ERROR([libpthread headers not found.])])
+
+])dnl
configure.ac +3 -0
index 25d2ba4..e0ecd61 100644
@@ -385,6 +385,9 @@ if test "$enable_gss" = yes; then
   dnl Invoked after AC_KERBEROS_V5; AC_LIBRPCSECGSS needs to have KRBLIBS set
   AC_LIBRPCSECGSS
 
+  dnl Check for pthreads
+  AC_LIBPTHREAD
+
   dnl librpcsecgss already has a dependency on libgssapi,
   dnl but we need to make sure we get the right version
   if test "$enable_gss" = yes; then
utils/gssd/Makefile.am +2 -1
index cb040b3..3f5f59a 100644
@@ -49,7 +49,8 @@ gssd_LDADD = \
 	$(RPCSECGSS_LIBS) \
 	$(KRBLIBS) \
 	$(GSSAPI_LIBS) \
-	$(LIBTIRPC)
+	$(LIBTIRPC) \
+	$(LIBPTHREAD)
 
 gssd_LDFLAGS = \
 	$(KRBLDFLAGS)
utils/gssd/gssd.c +40 -5

67 lines not on this page · raw message

utils/gssd/gssd.h +5 -0
index c6937c5..565bce3 100644
@@ -36,6 +36,7 @@
 #include <gssapi/gssapi.h>
 #include <event.h>
 #include <stdbool.h>
+#include <pthread.h>
 
 #ifndef GSSD_PIPEFS_DIR
 #define GSSD_PIPEFS_DIR		"/var/lib/nfs/rpc_pipefs"
@@ -61,6 +62,10 @@ extern int			root_uses_machine_creds;
 extern unsigned int 		context_timeout;
 extern unsigned int rpc_timeout;
 extern char			*preferred_realm;
+extern pthread_mutex_t ple_lock;
+extern pthread_cond_t pcond;
+extern pthread_mutex_t pmutex;
+extern int thread_started;
 
 struct clnt_info {
 	TAILQ_ENTRY(clnt_info)	list;
utils/gssd/gssd_proc.c +18 -31

72 lines not on this page · raw message

utils/gssd/krb5_util.c +3 -0
index 8ef8184..3328696 100644
@@ -128,6 +128,7 @@
 
 /* Global list of principals/cache file names for machine credentials */
 struct gssd_k5_kt_princ *gssd_k5_kt_princ_list = NULL;
+pthread_mutex_t ple_lock = PTHREAD_MUTEX_INITIALIZER;
 
 #ifdef HAVE_SET_ALLOWABLE_ENCTYPES
 int limit_to_legacy_enctypes = 0;
@@ -586,10 +587,12 @@ get_ple_by_princ(krb5_context context, krb5_principal princ)
 
 	/* Need to serialize list if we ever become multi-threaded! */
 
+	pthread_mutex_lock(&ple_lock);
 	ple = find_ple_by_princ(context, princ);
 	if (ple == NULL) {
 		ple = new_ple(context, princ);
 	}
+	pthread_mutex_unlock(&ple_lock);
 
 	return ple;
 }
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [PATCH v3 1/3] gssd: use pthreads to handle upcalls

Quoted 83 lines · Olga Kornievskaia

Currently, to persevere global data over multiple mounts, the root process does not fork when handling an upcall. Instead on not-forking create a pthread to handle the upcall since global data can be shared among threads.

---
 aclocal/libpthread.m4  | 13 +++++++++++++
 configure.ac           |  3 +++
 utils/gssd/Makefile.am |  3 ++-
 utils/gssd/gssd.c      | 45 ++++++++++++++++++++++++++++++++++++++++-----
 utils/gssd/gssd.h      |  5 +++++
 utils/gssd/gssd_proc.c | 49 ++++++++++++++++++-------------------------------
 utils/gssd/krb5_util.c |  3 +++
 7 files changed, 84 insertions(+), 37 deletions(-)
 create mode 100644 aclocal/libpthread.m4
aclocal/libpthread.m4 new file +13 -0
new file mode 100644
index 0000000..e87d2a0
@@ -0,0 +1,13 @@
+dnl Checks for pthreads library and headers
+dnl
+AC_DEFUN([AC_LIBPTHREAD], [
+
+    dnl Check for library, but do not add -lpthreads to LIBS
+    AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD=-lpthread],
+                 [AC_MSG_ERROR([libpthread not found.])])
+  AC_SUBST(LIBPTHREAD)
+
+  AC_CHECK_HEADERS([pthread.h], ,
+                   [AC_MSG_ERROR([libpthread headers not found.])])
+
+])dnl
configure.ac +3 -0
index 25d2ba4..e0ecd61 100644
@@ -385,6 +385,9 @@ if test "$enable_gss" = yes; then
   dnl Invoked after AC_KERBEROS_V5; AC_LIBRPCSECGSS needs to have KRBLIBS set
   AC_LIBRPCSECGSS
 
+  dnl Check for pthreads
+  AC_LIBPTHREAD
+
   dnl librpcsecgss already has a dependency on libgssapi,
   dnl but we need to make sure we get the right version
   if test "$enable_gss" = yes; then
utils/gssd/Makefile.am +2 -1
index cb040b3..3f5f59a 100644
@@ -49,7 +49,8 @@ gssd_LDADD = \
 	$(RPCSECGSS_LIBS) \
 	$(KRBLIBS) \
 	$(GSSAPI_LIBS) \
-	$(LIBTIRPC)
+	$(LIBTIRPC) \
+	$(LIBPTHREAD)
 
 gssd_LDFLAGS = \
 	$(KRBLDFLAGS)
utils/gssd/gssd.c +3 -1
index e7cb07f..0b7ffca 100644
@@ -87,7 +87,9 @@ unsigned int  rpc_timeout = 5;
 char *preferred_realm = NULL;
 /* Avoid DNS reverse lookups on server names */
 static bool avoid_dns = true;
-
+int thread_started = false;
+pthread_mutex_t pmutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t pcond = PTHREAD_COND_INITIALIZER;
 
 TAILQ_HEAD(topdir_list_head, topdir) topdir_list;
 
@@ -361,20 +363,53 @@ gssd_destroy_client(struct clnt_info *clp)
 
 static void gssd_scan(void);

utils/gssd/gssd.c gssd_destroy_client(struct clnt_info *clp) · line 374

Quoted 10 lines
utils/gssd/gssd.c +9 -0
 
+static void wait_for_child_and_detach(pthread_t th)
+{
+	pthread_mutex_lock(&pmutex);
+	while (!thread_started)
+		pthread_cond_wait(&pcond, &pmutex);
+	thread_started = false;
+	pthread_mutex_unlock(&pmutex);
+	pthread_detach(th);
+}

I was just looking at this... does it make more sense to make these types of routines inline instead of allocating stack space on every call...

With rpc.gssd, when running, is now involved every mount (even sec=sys ones) so I'm wondering if inlining 4 new routines would buy us anything...

One down fall with inline routines it makes more difficult to debug from gdb breakpoint point of view.

steved.

Quoted 173 lines
utils/gssd/gssd.c +28 -4
+
+/* For each upcall create a thread, detach from the main process so that
+ * resources are released back into the system without the need for a join.
+ * We need to wait for the child thread to start and consume the event from
+ * the file descriptor.
+ */
 static void
 gssd_clnt_gssd_cb(int UNUSED(fd), short UNUSED(which), void *data)
 {
 	struct clnt_info *clp = data;
-
-	handle_gssd_upcall(clp);
+	pthread_t th;
+	int ret;
+
+	ret = pthread_create(&th, NULL, (void *)handle_gssd_upcall,
+				(void *)clp);
+	if (ret != 0) {
+		printerr(0, "ERROR: pthread_create failed: ret %d: %s\n",
+			 ret, strerror(errno));
+		return;
+	}
+	wait_for_child_and_detach(th);
 }
 
 static void
 gssd_clnt_krb5_cb(int UNUSED(fd), short UNUSED(which), void *data)
 {
 	struct clnt_info *clp = data;
-
-	handle_krb5_upcall(clp);
+	pthread_t th;
+	int ret;
+
+	ret = pthread_create(&th, NULL, (void *)handle_krb5_upcall,
+				(void *)clp);
+	if (ret != 0) {
+		printerr(0, "ERROR: pthread_create failed: ret %d: %s\n",
+			 ret, strerror(errno));
+		return;
+	}
+	wait_for_child_and_detach(th);
 }
 
 static struct clnt_info *
utils/gssd/gssd.h +5 -0
index c6937c5..565bce3 100644
@@ -36,6 +36,7 @@
 #include <gssapi/gssapi.h>
 #include <event.h>
 #include <stdbool.h>
+#include <pthread.h>
 
 #ifndef GSSD_PIPEFS_DIR
 #define GSSD_PIPEFS_DIR		"/var/lib/nfs/rpc_pipefs"
@@ -61,6 +62,10 @@ extern int			root_uses_machine_creds;
 extern unsigned int 		context_timeout;
 extern unsigned int rpc_timeout;
 extern char			*preferred_realm;
+extern pthread_mutex_t ple_lock;
+extern pthread_cond_t pcond;
+extern pthread_mutex_t pmutex;
+extern int thread_started;
 
 struct clnt_info {
 	TAILQ_ENTRY(clnt_info)	list;
utils/gssd/gssd_proc.c +18 -31
index 1ef68d8..e2e95dc 100644
@@ -629,36 +629,6 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,
 	if (uid != 0 || (uid == 0 && root_uses_machine_creds == 0 &&
 				service == NULL)) {
 
-		/* already running as uid 0 */
-		if (uid == 0)
-			goto no_fork;
-
-		pid = fork();
-		switch(pid) {
-		case 0:
-			/* Child: fall through to rest of function */
-			childpid = getpid();
-			unsetenv("KRB5CCNAME");
-			printerr(2, "CHILD forked pid %d \n", childpid);
-			break;
-		case -1:
-			/* fork() failed! */
-			printerr(0, "WARNING: unable to fork() to handle"
-				"upcall: %s\n", strerror(errno));
-			return;
-		default:
-			/* Parent: just wait on child to exit and return */
-			do {
-				pid = wait(&err);
-			} while(pid == -1 && errno != -ECHILD);
-
-			if (WIFSIGNALED(err))
-				printerr(0, "WARNING: forked child was killed"
-					 "with signal %d\n", WTERMSIG(err));
-			return;
-		}
-no_fork:
-
 		auth = krb5_not_machine_creds(clp, uid, tgtname, &downcall_err,
 						&err, &rpc_clnt);
 		if (err)
@@ -735,12 +705,28 @@ out_return_error:
 	goto out;
 }
 
+/* signal to the parent thread that we have read from the file descriptor.
+ * it should allow the parent to proceed to poll on the descriptor for
+ * the next upcall from the kernel.
+ */
+static void
+signal_parent_event_consumed(void)
+{
+	pthread_mutex_lock(&pmutex);
+	thread_started = true;
+	pthread_cond_signal(&pcond);
+	pthread_mutex_unlock(&pmutex);
+}
+
 void
 handle_krb5_upcall(struct clnt_info *clp)
 {
 	uid_t			uid;
+	int 			status;
 
-	if (read(clp->krb5_fd, &uid, sizeof(uid)) < (ssize_t)sizeof(uid)) {
+	status = read(clp->krb5_fd, &uid, sizeof(uid)) < (ssize_t)sizeof(uid);
+	signal_parent_event_consumed();
+	if (status) {
 		printerr(0, "WARNING: failed reading uid from krb5 "
 			    "upcall pipe: %s\n", strerror(errno));
 		return;
@@ -765,6 +751,7 @@ handle_gssd_upcall(struct clnt_info *clp)
 	char			*enctypes = NULL;
 
 	lbuflen = read(clp->gssd_fd, lbuf, sizeof(lbuf));
+	signal_parent_event_consumed();
 	if (lbuflen <= 0 || lbuf[lbuflen-1] != '\n') {
 		printerr(0, "WARNING: handle_gssd_upcall: "
 			    "failed reading request\n");
utils/gssd/krb5_util.c +3 -0
index 8ef8184..3328696 100644
@@ -128,6 +128,7 @@
 
 /* Global list of principals/cache file names for machine credentials */
 struct gssd_k5_kt_princ *gssd_k5_kt_princ_list = NULL;
+pthread_mutex_t ple_lock = PTHREAD_MUTEX_INITIALIZER;
 
 #ifdef HAVE_SET_ALLOWABLE_ENCTYPES
 int limit_to_legacy_enctypes = 0;
@@ -586,10 +587,12 @@ get_ple_by_princ(krb5_context context, krb5_principal princ)
 
 	/* Need to serialize list if we ever become multi-threaded! */
 
+	pthread_mutex_lock(&ple_lock);
 	ple = find_ple_by_princ(context, princ);
 	if (ple == NULL) {
 		ple = new_ple(context, princ);
 	}
+	pthread_mutex_unlock(&ple_lock);
 
 	return ple;
 }
#3 lore raw

Re: [PATCH v3 1/3] gssd: use pthreads to handle upcalls

Quoted 103 lines · Steve Dickson
Quoted 83 lines · Olga Kornievskaia

Currently, to persevere global data over multiple mounts, the root process does not fork when handling an upcall. Instead on not-forking create a pthread to handle the upcall since global data can be shared among threads.

---

aclocal/libpthread.m4  | 13 +++++++++++++
configure.ac           |  3 +++
utils/gssd/Makefile.am |  3 ++-
utils/gssd/gssd.c      | 45 ++++++++++++++++++++++++++++++++++++++++-----
utils/gssd/gssd.h      |  5 +++++
utils/gssd/gssd_proc.c | 49 ++++++++++++++++++-------------------------------
utils/gssd/krb5_util.c |  3 +++
7 files changed, 84 insertions(+), 37 deletions(-)

create mode 100644 aclocal/libpthread.m4

aclocal/libpthread.m4 new file +13 -0
new file mode 100644
index 0000000..e87d2a0
@@ -0,0 +1,13 @@
+dnl Checks for pthreads library and headers
+dnl
+AC_DEFUN([AC_LIBPTHREAD], [
+
+    dnl Check for library, but do not add -lpthreads to LIBS
+    AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD=-lpthread],
+                 [AC_MSG_ERROR([libpthread not found.])])
+  AC_SUBST(LIBPTHREAD)
+
+  AC_CHECK_HEADERS([pthread.h], ,
+                   [AC_MSG_ERROR([libpthread headers not found.])])
+
+])dnl
configure.ac +3 -0
index 25d2ba4..e0ecd61 100644
@@ -385,6 +385,9 @@ if test "$enable_gss" = yes; then
  dnl Invoked after AC_KERBEROS_V5; AC_LIBRPCSECGSS needs to have KRBLIBS set
  AC_LIBRPCSECGSS
 
+  dnl Check for pthreads
+  AC_LIBPTHREAD
+
  dnl librpcsecgss already has a dependency on libgssapi,
  dnl but we need to make sure we get the right version
  if test "$enable_gss" = yes; then
utils/gssd/Makefile.am +2 -1
index cb040b3..3f5f59a 100644
@@ -49,7 +49,8 @@ gssd_LDADD = \
 	$(RPCSECGSS_LIBS) \
 	$(KRBLIBS) \
 	$(GSSAPI_LIBS) \
-	$(LIBTIRPC)
+	$(LIBTIRPC) \
+	$(LIBPTHREAD)
 
 gssd_LDFLAGS = \
 	$(KRBLDFLAGS)
utils/gssd/gssd.c +3 -1
index e7cb07f..0b7ffca 100644
@@ -87,7 +87,9 @@ unsigned int  rpc_timeout = 5;
 char *preferred_realm = NULL;
 /* Avoid DNS reverse lookups on server names */
 static bool avoid_dns = true;
-
+int thread_started = false;
+pthread_mutex_t pmutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t pcond = PTHREAD_COND_INITIALIZER;
 
 TAILQ_HEAD(topdir_list_head, topdir) topdir_list;
 
@@ -361,20 +363,53 @@ gssd_destroy_client(struct clnt_info *clp)
 
 static void gssd_scan(void);

utils/gssd/gssd.c gssd_destroy_client(struct clnt_info *clp) · line 374

Quoted 10 lines
utils/gssd/gssd.c +9 -0
 
+static void wait_for_child_and_detach(pthread_t th)
+{
+	pthread_mutex_lock(&pmutex);
+	while (!thread_started)
+		pthread_cond_wait(&pcond, &pmutex);
+	thread_started = false;
+	pthread_mutex_unlock(&pmutex);
+	pthread_detach(th);
+}

I was just looking at this... does it make more sense to make these types of routines inline instead of allocating stack space on every call...

Quoted 6 lines

With rpc.gssd, when running, is now involved every mount (even sec=sys ones) so I'm wondering if inlining 4 new routines would buy us anything...

One down fall with inline routines it makes more difficult to debug from gdb breakpoint point of view.

This doesn’t look like a function that we really need to step into, does it? I think inlining it would be ok.

I think the biggest saving would be to take the next step and do the pool of threads that are pre-created (and thus not taking time to be allocated for each upcall). Then we need a way to make sure we cleanup any threads that might be hanging for whatever reason.

Quoted 175 lines

steved.

Quoted 173 lines
utils/gssd/gssd.c +6 -0
+
+/* For each upcall create a thread, detach from the main process so that
+ * resources are released back into the system without the need for a join.
+ * We need to wait for the child thread to start and consume the event from
+ * the file descriptor.
+ */

static void
gssd_clnt_gssd_cb(int UNUSED(fd), short UNUSED(which), void *data)

{
	struct clnt_info *clp = data;
utils/gssd/gssd.c +11 -2
-
-	handle_gssd_upcall(clp);
+	pthread_t th;
+	int ret;
+
+	ret = pthread_create(&th, NULL, (void *)handle_gssd_upcall,
+				(void *)clp);
+	if (ret != 0) {
+		printerr(0, "ERROR: pthread_create failed: ret %d: %s\n",
+			 ret, strerror(errno));
+		return;
+	}
+	wait_for_child_and_detach(th);

}

static void
gssd_clnt_krb5_cb(int UNUSED(fd), short UNUSED(which), void *data)

{
	struct clnt_info *clp = data;
utils/gssd/gssd.c +11 -2
-
-	handle_krb5_upcall(clp);
+	pthread_t th;
+	int ret;
+
+	ret = pthread_create(&th, NULL, (void *)handle_krb5_upcall,
+				(void *)clp);
+	if (ret != 0) {
+		printerr(0, "ERROR: pthread_create failed: ret %d: %s\n",
+			 ret, strerror(errno));
+		return;
+	}
+	wait_for_child_and_detach(th);

}

static struct clnt_info *

utils/gssd/gssd.h +5 -0
index c6937c5..565bce3 100644
@@ -36,6 +36,7 @@
 #include <gssapi/gssapi.h>
 #include <event.h>
 #include <stdbool.h>
+#include <pthread.h>
 
 #ifndef GSSD_PIPEFS_DIR
 #define GSSD_PIPEFS_DIR		"/var/lib/nfs/rpc_pipefs"
@@ -61,6 +62,10 @@ extern int			root_uses_machine_creds;
 extern unsigned int 		context_timeout;
 extern unsigned int rpc_timeout;
 extern char			*preferred_realm;
+extern pthread_mutex_t ple_lock;
+extern pthread_cond_t pcond;
+extern pthread_mutex_t pmutex;
+extern int thread_started;
 
 struct clnt_info {
 	TAILQ_ENTRY(clnt_info)	list;
utils/gssd/gssd_proc.c +13 -30
index 1ef68d8..e2e95dc 100644
@@ -629,36 +629,6 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,
 	if (uid != 0 || (uid == 0 && root_uses_machine_creds == 0 &&
 				service == NULL)) {
 
-		/* already running as uid 0 */
-		if (uid == 0)
-			goto no_fork;
-
-		pid = fork();
-		switch(pid) {
-		case 0:
-			/* Child: fall through to rest of function */
-			childpid = getpid();
-			unsetenv("KRB5CCNAME");
-			printerr(2, "CHILD forked pid %d \n", childpid);
-			break;
-		case -1:
-			/* fork() failed! */
-			printerr(0, "WARNING: unable to fork() to handle"
-				"upcall: %s\n", strerror(errno));
-			return;
-		default:
-			/* Parent: just wait on child to exit and return */
-			do {
-				pid = wait(&err);
-			} while(pid == -1 && errno != -ECHILD);
-
-			if (WIFSIGNALED(err))
-				printerr(0, "WARNING: forked child was killed"
-					 "with signal %d\n", WTERMSIG(err));
-			return;
-		}
-no_fork:
-
 		auth = krb5_not_machine_creds(clp, uid, tgtname, &downcall_err,
 						&err, &rpc_clnt);
 		if (err)
@@ -735,12 +705,28 @@ out_return_error:
 	goto out;
 }
 
+/* signal to the parent thread that we have read from the file descriptor.
+ * it should allow the parent to proceed to poll on the descriptor for
+ * the next upcall from the kernel.
+ */
+static void
+signal_parent_event_consumed(void)
+{
+	pthread_mutex_lock(&pmutex);
+	thread_started = true;
+	pthread_cond_signal(&pcond);
+	pthread_mutex_unlock(&pmutex);
+}
+

void
handle_krb5_upcall(struct clnt_info *clp)

{
	uid_t			uid;
utils/gssd/gssd_proc.c +4 -1
+	int 			status;
 
-	if (read(clp->krb5_fd, &uid, sizeof(uid)) < (ssize_t)sizeof(uid)) {
+	status = read(clp->krb5_fd, &uid, sizeof(uid)) < (ssize_t)sizeof(uid);
+	signal_parent_event_consumed();
+	if (status) {
		printerr(0, "WARNING: failed reading uid from krb5 "
			    "upcall pipe: %s\n", strerror(errno));
		return;
utils/gssd/gssd_proc.c +1 -0
@@ -765,6 +751,7 @@ handle_gssd_upcall(struct clnt_info *clp)
 	char			*enctypes = NULL;
 
 	lbuflen = read(clp->gssd_fd, lbuf, sizeof(lbuf));
+	signal_parent_event_consumed();
 	if (lbuflen <= 0 || lbuf[lbuflen-1] != '\n') {
 		printerr(0, "WARNING: handle_gssd_upcall: "
 			    "failed reading request\n");
utils/gssd/krb5_util.c +3 -0
index 8ef8184..3328696 100644
@@ -128,6 +128,7 @@
 
 /* Global list of principals/cache file names for machine credentials */
 struct gssd_k5_kt_princ *gssd_k5_kt_princ_list = NULL;
+pthread_mutex_t ple_lock = PTHREAD_MUTEX_INITIALIZER;
 
 #ifdef HAVE_SET_ALLOWABLE_ENCTYPES
 int limit_to_legacy_enctypes = 0;
@@ -586,10 +587,12 @@ get_ple_by_princ(krb5_context context, krb5_principal princ)
 
 	/* Need to serialize list if we ever become multi-threaded! */
 
+	pthread_mutex_lock(&ple_lock);
 	ple = find_ple_by_princ(context, princ);
 	if (ple == NULL) {
 		ple = new_ple(context, princ);
 	}
+	pthread_mutex_unlock(&ple_lock);
 
 	return ple;
 }
#4 lore raw

Re: [PATCH v3 1/3] gssd: use pthreads to handle upcalls

Quoted 107 lines · Olga
Quoted 107 lines · Steve Dickson
Quoted 83 lines · Olga Kornievskaia

Currently, to persevere global data over multiple mounts, the root process does not fork when handling an upcall. Instead on not-forking create a pthread to handle the upcall since global data can be shared among threads.

---

aclocal/libpthread.m4  | 13 +++++++++++++
configure.ac           |  3 +++
utils/gssd/Makefile.am |  3 ++-
utils/gssd/gssd.c      | 45 ++++++++++++++++++++++++++++++++++++++++-----
utils/gssd/gssd.h      |  5 +++++
utils/gssd/gssd_proc.c | 49 ++++++++++++++++++-------------------------------
utils/gssd/krb5_util.c |  3 +++
7 files changed, 84 insertions(+), 37 deletions(-)

create mode 100644 aclocal/libpthread.m4

aclocal/libpthread.m4 new file +13 -0
new file mode 100644
index 0000000..e87d2a0
@@ -0,0 +1,13 @@
+dnl Checks for pthreads library and headers
+dnl
+AC_DEFUN([AC_LIBPTHREAD], [
+
+    dnl Check for library, but do not add -lpthreads to LIBS
+    AC_CHECK_LIB([pthread], [pthread_create], [LIBPTHREAD=-lpthread],
+                 [AC_MSG_ERROR([libpthread not found.])])
+  AC_SUBST(LIBPTHREAD)
+
+  AC_CHECK_HEADERS([pthread.h], ,
+                   [AC_MSG_ERROR([libpthread headers not found.])])
+
+])dnl
configure.ac +3 -0
index 25d2ba4..e0ecd61 100644
@@ -385,6 +385,9 @@ if test "$enable_gss" = yes; then
  dnl Invoked after AC_KERBEROS_V5; AC_LIBRPCSECGSS needs to have KRBLIBS set
  AC_LIBRPCSECGSS
 
+  dnl Check for pthreads
+  AC_LIBPTHREAD
+
  dnl librpcsecgss already has a dependency on libgssapi,
  dnl but we need to make sure we get the right version
  if test "$enable_gss" = yes; then
utils/gssd/Makefile.am +2 -1
index cb040b3..3f5f59a 100644
@@ -49,7 +49,8 @@ gssd_LDADD = \
 	$(RPCSECGSS_LIBS) \
 	$(KRBLIBS) \
 	$(GSSAPI_LIBS) \
-	$(LIBTIRPC)
+	$(LIBTIRPC) \
+	$(LIBPTHREAD)
 
 gssd_LDFLAGS = \
 	$(KRBLDFLAGS)
utils/gssd/gssd.c +3 -1
index e7cb07f..0b7ffca 100644
@@ -87,7 +87,9 @@ unsigned int  rpc_timeout = 5;
 char *preferred_realm = NULL;
 /* Avoid DNS reverse lookups on server names */
 static bool avoid_dns = true;
-
+int thread_started = false;
+pthread_mutex_t pmutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_cond_t pcond = PTHREAD_COND_INITIALIZER;
 
 TAILQ_HEAD(topdir_list_head, topdir) topdir_list;
 
@@ -361,20 +363,53 @@ gssd_destroy_client(struct clnt_info *clp)
 
 static void gssd_scan(void);

utils/gssd/gssd.c gssd_destroy_client(struct clnt_info *clp) · line 374

Quoted 10 lines
utils/gssd/gssd.c +9 -0
 
+static void wait_for_child_and_detach(pthread_t th)
+{
+	pthread_mutex_lock(&pmutex);
+	while (!thread_started)
+		pthread_cond_wait(&pcond, &pmutex);
+	thread_started = false;
+	pthread_mutex_unlock(&pmutex);
+	pthread_detach(th);
+}

I was just looking at this... does it make more sense to make these types of routines inline instead of allocating stack space on every call...

With rpc.gssd, when running, is now involved every mount (even sec=sys ones) so I'm wondering if inlining 4 new routines would buy us anything...

Quoted 5 lines
Quoted 2 lines

One down fall with inline routines it makes more difficult to debug from gdb breakpoint point of view.

This doesn’t look like a function that we really need to step into, does it? I think inlining it would be ok.

No it does not... inlining it is...

Quoted 6 lines

I think the biggest saving would be to take the next step and do the pool of threads that are pre-created (and thus not taking time to be allocated for each upcall). Then we need a way to make sure we cleanup any threads that might be hanging for whatever reason.

This will be an excellent next step!

steved.

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Re: [PATCH v3 1/3] gssd: use pthreads to handle upcalls

Quoted 5 lines · Olga
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

I think the biggest saving would be to take the next step and do the pool of threads that are pre-created (and thus not taking time to be allocated for each upcall). Then we need a way to make sure we cleanup any threads that might be hanging for whatever reason.

Quoted 7 lines
Quoted 7 lines
Quoted 1 line

This will be an excellent next step!

This patch series is suppose to show ‘proof-of-concept’ and functionally equivalent but better to what we have now.
Old: upcall -> new process. New: upcall -> new thread.
Old: process hangs -> resources not cleaned and no new upcalls.
New: thread hangs -> resources not cleaned and new upcalls can proceed.

Well I think you proved it... Nice work!

Quoted 9 lines
Quoted 4 lines

I will submit the new version with:
— make function inline
— change setresuid/setresgid to set all three uids: real, effective, saved. git blame tells me Jeff you wrote the comment about attacks from ptrace().

Sorry I unintentionally hit send. I wanted to say that then I’ll work on getting the pool of thread but working on top of these patches. Or do you want me to keep working and then submit that version as if this one wasn’t written?

Let's get these in now so they will get some real world testing... So lets build on these...

steved.

#8 lore raw

PATCH v3 2/3 gssd: using syscalls directly to change thread's identity

In reply to Olga Kornievskaia

For the threaded version we have to set uid,gid per thread instead of per process. glibc setresuid() when called from a thread, it'll send a signal to all other threads to synchronize the uid in all other threads. To bypass this, we have to call syscall() directly.

---
 utils/gssd/gssd_proc.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
utils/gssd/gssd_proc.c +9 -3
index e2e95dc..487a4f5 100644
@@ -69,6 +69,7 @@
 #include <netdb.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <syscall.h>
 
 #include "gssd.h"
 #include "err_util.h"
@@ -436,7 +437,7 @@ change_identity(uid_t uid)
 	struct passwd	*pw;
 
 	/* drop list of supplimentary groups first */
-	if (setgroups(0, NULL) != 0) {
+	if (syscall(SYS_setgroups, 0) != 0) {
 		printerr(0, "WARNING: unable to drop supplimentary groups!");
 		return errno;
 	}
@@ -457,7 +458,12 @@ change_identity(uid_t uid)
 	 * Switch the GIDs. Note that we leave the saved-set-gid alone in an
 	 * attempt to prevent attacks via ptrace()
 	 */
-	if (setresgid(pw->pw_gid, pw->pw_gid, -1) != 0) {
+	/* For the threaded version we have to set uid,gid per thread instead
+	 * of per process. glibc setresuid() when called from a thread, it'll
+	 * send a signal to all other threads to synchronize the uid in all
+	 * other threads. To bypass this, we have to call syscall() directly.
+	 */
+	if (syscall(SYS_setresgid, pw->pw_gid) != 0) {
 		printerr(0, "WARNING: failed to set gid to %u!\n", pw->pw_gid);
 		return errno;
 	}
@@ -466,7 +472,7 @@ change_identity(uid_t uid)
 	 * Switch UIDs, but leave saved-set-uid alone to prevent ptrace() by
 	 * other processes running with this uid.
 	 */
-	if (setresuid(uid, uid, -1) != 0) {
+	if (syscall(SYS_setresuid, uid) != 0) {
 		printerr(0, "WARNING: Failed to setuid for user with uid %u\n",
 				uid);
 		return errno;
Signature · 1 line
1.8.3.1
#9 lore raw

Re: [PATCH v3 2/3] gssd: using syscalls directly to change thread's identity

Quoted 47 lines · Olga Kornievskaia

For the threaded version we have to set uid,gid per thread instead of per process. glibc setresuid() when called from a thread, it'll send a signal to all other threads to synchronize the uid in all other threads. To bypass this, we have to call syscall() directly.

---
 utils/gssd/gssd_proc.c | 12 +++++++++---

 1 file changed, 9 insertions(+), 3 deletions(-)
utils/gssd/gssd_proc.c +1 -0
index e2e95dc..487a4f5 100644
@@ -69,6 +69,7 @@
  #include 
  #include 
  #include 
+#include 


 #include "gssd.h"
 #include "err_util.h"

utils/gssd/gssd_proc.c +0 -0
@@ -436,7 +437,7 @@ change_identity(uid_t uid)
  	struct passwd	*pw;


  /* drop list of supplimentary groups first */

utils/gssd/gssd_proc.c +1 -1
-	if (setgroups(0, NULL) != 0) {
+	if (syscall(SYS_setgroups, 0) != 0) {

  printerr(0, "WARNING: unable to drop supplimentary groups!"); return errno;
  }

utils/gssd/gssd_proc.c +6 -1
@@ -457,7 +458,12 @@ change_identity(uid_t uid)
  	 * Switch the GIDs. Note that we leave the saved-set-gid alone in an
  	 * attempt to prevent attacks via ptrace()
  	 */
-	if (setresgid(pw->pw_gid, pw->pw_gid, -1) != 0) {
+	/* For the threaded version we have to set uid,gid per thread instead
+	 * of per process. glibc setresuid() when called from a thread, it'll
+	 * send a signal to all other threads to synchronize the uid in all
+	 * other threads. To bypass this, we have to call syscall() directly.
+	 */
+	if (syscall(SYS_setresgid, pw->pw_gid) != 0) {
  		printerr(0, "WARNING: failed to set gid to %u!\n", pw->pw_gid);
  		return errno;
  	}

utils/gssd/gssd_proc.c change_identity(uid_t uid) · line 475

Quoted 5 lines
utils/gssd/gssd_proc.c +1 -1
@@ -466,7 +472,7 @@ change_identity(uid_t uid)
  	 * Switch UIDs, but leave saved-set-uid alone to prevent ptrace() by
  	 * other processes running with this uid.
  	 */
-	if (setresuid(uid, uid, -1) != 0) {
+	if (syscall(SYS_setresuid, uid) != 0) {

That looks wrong. setresuid takes 3 arguments:

SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)

Ditto for setresgid above. syscall is a varargs function, so you really _must_ pass in the right number of args or you'll end up feeding it random junk in registers or off the stack. The compiler won't save you here...

Quoted 1 line

  printerr(0, "WARNING: Failed to setuid for user with

uid %u\n",

Quoted 2 lines

  uid);
  return errno;

Signature · 1 line
Jeff Layton <[email protected]>
#10 lore raw

Re: [PATCH v3 2/3] gssd: using syscalls directly to change thread's identity

DQo+IE9uIEFwciAyNSwgMjAxNiwgYXQgNDoyMyBQTSwgSmVmZiBMYXl0b24gPGpsYXl0b25AcG9v Y2hpZXJlZHMubmV0PiB3cm90ZToNCj4gDQo+IE9uIE1vbiwgMjAxNi0wNC0yNSBhdCAxMjo1OCAt MDQwMCwgT2xnYSBLb3JuaWV2c2thaWEgd3JvdGU6DQo+PiBGb3IgdGhlIHRocmVhZGVkIHZlcnNp b24gd2UgaGF2ZSB0byBzZXQgdWlkLGdpZCBwZXIgdGhyZWFkIGluc3RlYWQNCj4+IG9mIHBlciBw cm9jZXNzLiBnbGliYyBzZXRyZXN1aWQoKSB3aGVuIGNhbGxlZCBmcm9tIGEgdGhyZWFkLCBpdCds bA0KPj4gc2VuZCBhIHNpZ25hbCB0byBhbGwgb3RoZXIgdGhyZWFkcyB0byBzeW5jaHJvbml6ZSB0 aGUgdWlkIGluIGFsbA0KPj4gb3RoZXIgdGhyZWFkcy4gVG8gYnlwYXNzIHRoaXMsIHdlIGhhdmUg dG8gY2FsbCBzeXNjYWxsKCkgZGlyZWN0bHkuDQo+PiANCj4+IFNpZ25lZC1vZmYtYnk6IE9sZ2Eg S29ybmlldnNrYWlhIDxrb2xnYUBuZXRhcHAuY29tPg0KPj4gUmV2aWV3ZWQtYnk6IFN0ZXZlIERp Y2tzb24gPHN0ZXZlZEByZWRoYXQuY29tPg0KPj4gLS0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skaia

Previously the location of the credential cache was passed in either using environment variable KRB5CCNAME or gss_krb5_ccache_name() if supported. For threaded-gssd, we can't use an environment variable as it's shared among all thread. Thus always use the api call.

---
 utils/gssd/gssd_proc.c | 12 +++++++++--
 utils/gssd/krb5_util.c | 56 +++++++++-----------------------------------------
 utils/gssd/krb5_util.h |  1 -
 3 files changed, 20 insertions(+), 49 deletions(-)
utils/gssd/gssd_proc.c +10 -2
index 487a4f5..c9ba399 100644
@@ -554,7 +554,15 @@ krb5_use_machine_creds(struct clnt_info *clp, uid_t uid, char *tgtname,
 			goto out;
 		}
 		for (ccname = credlist; ccname && *ccname; ccname++) {
-			gssd_setup_krb5_machine_gss_ccache(*ccname);
+			u_int min_stat;
+
+			if (gss_krb5_ccache_name(&min_stat, *ccname, NULL) !=
+					GSS_S_COMPLETE) {
+				printerr(1, "WARNING: gss_krb5_ccache_name "
+					 "with name '%s' failed (%s)\n",
+					 *ccname, error_message(min_stat));
+				continue;
+			}
 			if ((create_auth_rpc_client(clp, tgtname, rpc_clnt,
 						&auth, uid,
 						AUTHTYPE_KRB5,
@@ -575,7 +583,7 @@ krb5_use_machine_creds(struct clnt_info *clp, uid_t uid, char *tgtname,
 					 "recreate cache for server %s\n",
 					clp->servername);
 			} else {
-				printerr(1, "WARNING: Failed to create machine"
+				printerr(0, "ERROR: Failed to create machine"
 					 "krb5 context with any credentials"
 					 "cache for server %s\n",
 					clp->servername);
utils/gssd/krb5_util.c +10 -46

75 lines not on this page · raw message

utils/gssd/krb5_util.h +0 -1
index a319588..d3b0777 100644
@@ -27,7 +27,6 @@ int gssd_setup_krb5_user_gss_ccache(uid_t uid, char *servername,
 				     char *dirname);
 int  gssd_get_krb5_machine_cred_list(char ***list);
 void gssd_free_krb5_machine_cred_list(char **list);
-void gssd_setup_krb5_machine_gss_ccache(char *servername);
 void gssd_destroy_krb5_machine_creds(void);
 int  gssd_refresh_krb5_machine_credential(char *hostname,
 					  struct gssd_k5_kt_princ *ple, 
Signature · 1 line
1.8.3.1