diff mbox

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

Message ID 1384526265-4494-1-git-send-email-jlayton@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jeff Layton Nov. 15, 2013, 2:37 p.m. UTC
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.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 utils/gssd/gssd_proc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Steve Dickson Nov. 20, 2013, 9:23 p.m. UTC | #1
On 15/11/13 09:37, Jeff Layton wrote:
> 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.
> 
> Signed-off-by: Jeff Layton <jlayton@redhat.com>
Committed (tag: nfs-utils-1-2-10-rc1)

steved.
> ---
>  utils/gssd/gssd_proc.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> index b48d163..447aec1 100644
> --- a/utils/gssd/gssd_proc.c
> +++ b/utils/gssd/gssd_proc.c
> @@ -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));
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
index b48d163..447aec1 100644
--- a/utils/gssd/gssd_proc.c
+++ b/utils/gssd/gssd_proc.c
@@ -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));