* [PATCH] [RFC] coredump: Ensure that the coredump helper has stdout and stderr
@ 2012-09-28 16:32 Richard Weinberger
2012-10-04 11:07 ` Richard Weinberger
0 siblings, 1 reply; 2+ messages in thread
From: Richard Weinberger @ 2012-09-28 16:32 UTC (permalink / raw)
To: viro; +Cc: linux-fsdevel, linux-kernel, Richard Weinberger
Currently only stdin is available in the coredump helper process.
If the process opens a file and then issues a printf(),
printf() will write to that opened file instead to a console.
Therefore open /dev/console and create fd 1 and 0 as init/main.c does.
sys_close(0) is only needed if sys_open() succeeds.
Before this patch it was in vain and returned always -EBADF because nobody
opened fd 0.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
fs/exec.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/fs/exec.c b/fs/exec.c
index 574cf4d..2912fec 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -2079,7 +2079,13 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
cp->file = files[1];
- sys_close(0);
+ /* Ensure that the process has stdout and stderr */
+ if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) == 0) {
+ sys_dup(0);
+ sys_dup(0);
+ sys_close(0);
+ }
+
fd_install(0, files[0]);
spin_lock(&cf->file_lock);
fdt = files_fdtable(cf);
--
1.7.11.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [RFC] coredump: Ensure that the coredump helper has stdout and stderr
2012-09-28 16:32 [PATCH] [RFC] coredump: Ensure that the coredump helper has stdout and stderr Richard Weinberger
@ 2012-10-04 11:07 ` Richard Weinberger
0 siblings, 0 replies; 2+ messages in thread
From: Richard Weinberger @ 2012-10-04 11:07 UTC (permalink / raw)
To: Richard Weinberger; +Cc: viro, linux-fsdevel, linux-kernel
On 28.09.2012 18:32, Richard Weinberger wrote:
> Currently only stdin is available in the coredump helper process.
> If the process opens a file and then issues a printf(),
> printf() will write to that opened file instead to a console.
>
> Therefore open /dev/console and create fd 1 and 0 as init/main.c does.
> sys_close(0) is only needed if sys_open() succeeds.
> Before this patch it was in vain and returned always -EBADF because nobody
> opened fd 0.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> fs/exec.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/fs/exec.c b/fs/exec.c
> index 574cf4d..2912fec 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -2079,7 +2079,13 @@ static int umh_pipe_setup(struct subprocess_info *info, struct cred *new)
>
> cp->file = files[1];
>
> - sys_close(0);
> + /* Ensure that the process has stdout and stderr */
> + if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) == 0) {
> + sys_dup(0);
> + sys_dup(0);
> + sys_close(0);
> + }
> +
> fd_install(0, files[0]);
> spin_lock(&cf->file_lock);
> fdt = files_fdtable(cf);
>
Ping?
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-10-04 11:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-28 16:32 [PATCH] [RFC] coredump: Ensure that the coredump helper has stdout and stderr Richard Weinberger
2012-10-04 11:07 ` Richard Weinberger
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 NNTP newsgroup(s).