From: "Paolo 'Blaisorblade' Giarrusso" <blaisorblade@yahoo.it>
To: Andrew Morton <akpm@osdl.org>
Cc: Jeff Dike <jdike@addtoit.com>,
linux-kernel@vger.kernel.org,
user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] [PATCH 12/17] uml: fix hang on run_helper() failure on uml_net
Date: Fri, 07 Apr 2006 16:31:17 +0200 [thread overview]
Message-ID: <20060407143117.19201.85132.stgit@zion.home.lan> (raw)
In-Reply-To: <20060407142709.19201.99196.stgit@zion.home.lan>
From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Fix an hang on a pipe when run_helper() fails when called by change_tramp()
(i.e. when calling uml_net) - reproduced the bug and verified this fixes it.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
---
arch/um/drivers/net_user.c | 4 +++-
arch/um/os-Linux/helper.c | 10 +++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/arch/um/drivers/net_user.c b/arch/um/drivers/net_user.c
index 0e2f061..0a7786e 100644
--- a/arch/um/drivers/net_user.c
+++ b/arch/um/drivers/net_user.c
@@ -182,7 +182,9 @@ static int change_tramp(char **argv, cha
pe_data.stdout = fds[1];
pid = run_helper(change_pre_exec, &pe_data, argv, NULL);
- read_output(fds[0], output, output_len);
+ if (pid > 0) /* Avoid hang as we won't get data in failure case. */
+ read_output(fds[0], output, output_len);
+
os_close_file(fds[0]);
os_close_file(fds[1]);
diff --git a/arch/um/os-Linux/helper.c b/arch/um/os-Linux/helper.c
index 6490a4f..6987d1d 100644
--- a/arch/um/os-Linux/helper.c
+++ b/arch/um/os-Linux/helper.c
@@ -43,7 +43,7 @@ static int helper_child(void *arg)
(*data->pre_exec)(data->pre_data);
execvp(argv[0], argv);
errval = errno;
- printk("execvp of '%s' failed - errno = %d\n", argv[0], errno);
+ printk("helper_child - execve of '%s' failed - errno = %d\n", argv[0], errno);
os_write_file(data->fd, &errval, sizeof(errval));
kill(os_getpid(), SIGKILL);
return(0);
@@ -92,15 +92,15 @@ int run_helper(void (*pre_exec)(void *),
close(fds[1]);
fds[1] = -1;
- /*Read the errno value from the child.*/
+ /* Read the errno value from the child, if the exec failed, or get 0 if
+ * the exec succeeded because the pipe fd was set as close-on-exec. */
n = os_read_file(fds[0], &ret, sizeof(ret));
- if(n < 0){
+ if (n < 0) {
printk("run_helper : read on pipe failed, ret = %d\n", -n);
ret = n;
kill(pid, SIGKILL);
CATCH_EINTR(waitpid(pid, NULL, 0));
- }
- else if(n != 0){
+ } else if(n != 0){
CATCH_EINTR(n = waitpid(pid, NULL, 0));
ret = -errno;
} else {
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
next prev parent reply other threads:[~2006-04-07 14:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-07 14:27 [uml-devel] [PATCH 00/17] Uml little fixups for new and existing code [for 2.6.17] Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:30 ` [uml-devel] [PATCH 01/17] uml: make 64-bit COW files compatible with 32-bit ones Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:30 ` [uml-devel] [PATCH 02/17] uml: safe migration path to the correct V3 COW format Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:30 ` [uml-devel] [PATCH 03/17] uml: fix 2 harmless cast warnings for 64-bit Paolo 'Blaisorblade' Giarrusso
2006-04-07 16:02 ` [uml-devel] " Jeff Dike
2006-04-07 21:46 ` Blaisorblade
2006-04-07 14:30 ` [uml-devel] [PATCH 04/17] uml: request format warnings to GCC for appropriate functions Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 05/17] uml: fix format errors Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 06/17] uml: fix some double export warnings Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 07/17] uml: fix "extern-vs-static" proto conflict in TLS code Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 08/17] uml: prepare fixing compilation output Paolo 'Blaisorblade' Giarrusso
2006-04-07 16:05 ` [uml-devel] " Jeff Dike
2006-04-07 21:50 ` Blaisorblade
2006-04-07 14:31 ` [uml-devel] [PATCH 09/17] uml: fix critical typo for TT mode Paolo 'Blaisorblade' Giarrusso
2006-04-07 15:45 ` [uml-devel] " Jeff Dike
2006-04-07 14:31 ` [uml-devel] [PATCH 10/17] uml: support sparse for userspace files Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 11/17] uml: move outside spinlock call not needing it Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` Paolo 'Blaisorblade' Giarrusso [this message]
2006-04-07 14:31 ` [uml-devel] [PATCH 13/17] uml: fix failure path after conversion Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 14/17] uml: fix big stack user Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 15/17] uml: local_irq_save, not local_save_flags Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 16/17] uml: fix parallel make early failure on clean tree Paolo 'Blaisorblade' Giarrusso
2006-04-07 14:31 ` [uml-devel] [PATCH 17/17] uml: avoid warnings for diffent names for an unsigned quadword Paolo 'Blaisorblade' Giarrusso
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060407143117.19201.85132.stgit@zion.home.lan \
--to=blaisorblade@yahoo.it \
--cc=akpm@osdl.org \
--cc=jdike@addtoit.com \
--cc=linux-kernel@vger.kernel.org \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox