lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1349824269-18776-1-git-send-email-richard@nod.at>
Date:	Wed, 10 Oct 2012 01:11:09 +0200
From:	Richard Weinberger <richard@....at>
To:	viro@...iv.linux.org.uk
Cc:	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	Richard Weinberger <richard@....at>
Subject: [RESEND] [PATCH] [RFC] coredump: Ensure that the coredump helper has stdout and stderr

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@....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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ