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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 20 Mar 2014 15:11:59 +0530
From:	Janani Venkataraman <jananive@...ux.vnet.ibm.com>
To:	linux-kernel@...r.kernel.org
Cc:	amwang@...hat.com, procps@...elists.org, rdunlap@...otime.net,
	james.hogan@...tec.com, aravinda@...ux.vnet.ibm.com, hch@....de,
	mhiramat@...hat.com, jeremy.fitzhardinge@...rix.com,
	xemul@...allels.com, d.hatayama@...fujitsu.com, coreutils@....org,
	kosaki.motohiro@...fujitsu.com, adobriyan@...il.com,
	util-linux@...r.kernel.org, tarundsk@...ux.vnet.ibm.com,
	vapier@...too.org, roland@...k.frob.com, ananth@...ux.vnet.ibm.com,
	gorcunov@...nvz.org, avagin@...nvz.org, oleg@...hat.com,
	eparis@...hat.com, suzuki@...ux.vnet.ibm.com, andi@...stfloor.org,
	tj@...nel.org, akpm@...ux-foundation.org,
	torvalds@...ux-foundation.org
Subject: [PATCH 22/33] Dump the task

Now we have the PID and the absolute or relative path of the core. We now call
the do_coredump function with the appropriate parameters.

Signed-off-by: Janani Venkataraman <jananive@...ux.vnet.ibm.com>
---
 src/coredump.c |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/src/coredump.c b/src/coredump.c
index 599a912..72ba8d8 100755
--- a/src/coredump.c
+++ b/src/coredump.c
@@ -446,6 +446,61 @@ int get_client_pid(struct ucred *client_info)
 	return 0;
 }
 
+/* Dumps the client process */
+int dump_task(struct ucred *client_info, char *core_file)
+{
+
+	char filename[40], cwd[CORE_FILE_NAME_SZ], corefile[CORE_FILE_NAME_SZ];
+	memset(filename, 0, 40);
+	memset(cwd, 0, CORE_FILE_NAME_SZ);
+	memset(corefile, 0, CORE_FILE_NAME_SZ);
+
+	if (setgid(client_info->gid)) {
+		send_reply(errno);
+		gencore_log("[%d]: Could not change GID:%s\n",
+				pid_log, strerror(errno));
+		return -1;
+	}
+
+	if (setuid(client_info->uid)) {
+		send_reply(errno);
+		gencore_log("[%d]: Could not change UID:%s\n",
+				pid_log, strerror(errno));
+		return -1;
+	}
+
+	/* Checking if UID was changed */
+	if (geteuid() != client_info->uid) {
+		send_reply(errno);
+		gencore_log("[%d]: Could not change UID:%s\n",
+				pid_log, strerror(errno));
+		return -1;
+	}
+
+	/* Converting the path to absolute path */
+	if (core_file[0] != '/') {
+		snprintf(filename, 40, "/proc/%d/cwd", client_info->pid);
+		readlink(filename, cwd, CORE_FILE_NAME_SZ);
+		snprintf(corefile, CORE_FILE_NAME_SZ, "%s/%s", cwd, core_file);
+	} else
+		strcpy(corefile, core_file);
+
+	if (do_coredump(client_info->pid, (char *)corefile)) {
+		send_reply(errno);
+		gencore_log("[%d]: Could not create core file %s.\n",
+						pid_log, corefile);
+		fflush(fp_log);
+		return -1;
+	}
+
+	gencore_log("[%d]: Core file %s created.\n", pid_log,
+							corefile);
+
+	send_reply(0);
+
+	return 0;
+}
+
 /* Services requests */
 int service_request(void)
 {
@@ -463,6 +518,11 @@ int service_request(void)
 	if (ret)
 		goto cleanup;
 
+	/* Dump process */
+	ret = dump_task(&client_info, core_file);
+	if (ret)
+		goto cleanup;
+
 cleanup:
 	close(new_sock);
 	if (ret == -1)

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