Skip to contentSkip to conversation

gssd: don't let spurious signals interrupt the wait after forking

PATCH In review Jeff Layton 2 participants 2 messages Nov 15, 2013 – Nov 20, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gssd: don't let spurious signals interrupt the wait after forking

Because gssd uses dnotify under the hood, it's easily possible that the parent process can catch a signal while processing an upcall. If that happens, then we'll currently exit the wait for the child task to exit, and it'll end up as a zombie.

Fix this by ensuring that we only wait for the child to actually exit.

---
 utils/gssd/gssd_proc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
utils/gssd/gssd_proc.c +4 -1
index b48d163..447aec1 100644
@@ -1040,7 +1040,10 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,
 		return;
 	default:
 		/* Parent: just wait on child to exit and return */
-		wait(&err);
+		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));
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 8 lines · Jeff Layton

Because gssd uses dnotify under the hood, it's easily possible that the parent process can catch a signal while processing an upcall. If that happens, then we'll currently exit the wait for the child task to exit, and it'll end up as a zombie.

Fix this by ensuring that we only wait for the child to actually exit.

Committed (tag: nfs-utils-1-2-10-rc1)

steved.

Quoted 21 lines
---
 utils/gssd/gssd_proc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
utils/gssd/gssd_proc.c +4 -1
index b48d163..447aec1 100644
@@ -1040,7 +1040,10 @@ process_krb5_upcall(struct clnt_info *clp, uid_t uid, int fd, char *tgtname,
 		return;
 	default:
 		/* Parent: just wait on child to exit and return */
-		wait(&err);
+		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));