git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Erik E Brady <brady@cisco.com>
To: git@vger.kernel.org
Cc: Erik E Brady <brady@cisco.com>
Subject: [PATCH] credential: cred helper fast exit can cause SIGPIPE, crash
Date: Wed, 28 Mar 2018 15:20:51 -0700	[thread overview]
Message-ID: <20180328222051.23684-1-brady@cisco.com> (raw)

credential.c, run_credential_helper(): now ignores SIGPIPE
when writing to credential helper.  Avoids problem with race
where cred helper exits very quickly and, after, git tries
to write to it, generating SIGPIPE and crashing git.  To
reproduce this the cred helper must not read from STDIN.

This was seen with a custom credential helper, written in
Go, which ignored the store command (STDIN not read) and
then did a quick exit.  Even with this fast helper the race
was pretty rare, ie: was only seen on some of our older VM's
running 2.6.18-416.el5 #1 SMP linux for whatever reason.  On
these VM's it occurred only once every few hundred git cmds.
---
 credential.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/credential.c b/credential.c
index 9747f47b1..62be651b0 100644
--- a/credential.c
+++ b/credential.c
@@ -5,6 +5,7 @@
 #include "run-command.h"
 #include "url.h"
 #include "prompt.h"
+#include "sigchain.h"
 
 void credential_init(struct credential *c)
 {
@@ -227,8 +228,10 @@ static int run_credential_helper(struct credential *c,
 		return -1;
 
 	fp = xfdopen(helper.in, "w");
+	sigchain_push(SIGPIPE, SIG_IGN);
 	credential_write(c, fp);
 	fclose(fp);
+	sigchain_pop(SIGPIPE);
 
 	if (want_output) {
 		int r;
-- 
2.16.3.dirty


             reply	other threads:[~2018-03-28 22:21 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 22:20 Erik E Brady [this message]
2018-03-29 11:19 ` [PATCH] credential: cred helper fast exit can cause SIGPIPE, crash Jeff King
2018-03-29 17:25   ` Erik Brady -X (brady - ROBERT HALF INTERNATIONAL INC at Cisco)
2018-03-29 17:55     ` Jeff King
2018-03-29 18:00       ` [PATCH] credential: ignore SIGPIPE when writing to credential helpers Erik E Brady
2018-03-29 21:51         ` Jeff King
2018-03-29 22:20           ` Erik Brady -X (brady - ROBERT HALF INTERNATIONAL INC at Cisco)
2018-03-29 22:29             ` Jeff King
2018-03-29 22:35           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180328222051.23684-1-brady@cisco.com \
    --to=brady@cisco.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).