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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 20 Mar 2014 15:09:58 +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 07/33] Do elf_coredump

Perform the actual dump depending on whether it is 32 bit or 64 bit.

We create three files elf.c elf32.c and elf64.c. In elf.c we have all the elf
related code in a generic format(not 32 or 64 bit specific). In elf32.c and
elf64.c we include elf.c and #define the required datatypes and functions into
32 or 64 specific values respectively.

Essentially we have two copies of elf.c, one which is 32 bit specific and the
other 64 bit specific and hence the appropriate function is called based on the
application to be dumped.

Signed-off-by: Janani Venkataraman <jananive@...ux.vnet.ibm.com>
---
 src/Makefile.am |    2 +-
 src/coredump.c  |    9 +++++++++
 src/elf.c       |   31 +++++++++++++++++++++++++++++++
 src/elf32.c     |   33 +++++++++++++++++++++++++++++++++
 src/elf64.c     |   33 +++++++++++++++++++++++++++++++++
 5 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 src/elf.c
 create mode 100644 src/elf32.c
 create mode 100644 src/elf64.c

diff --git a/src/Makefile.am b/src/Makefile.am
index 9e5d3c0..90d8b25 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -3,5 +3,5 @@ HAVE_SYSTEMD_SOCKET_SUPPORT = 0
 CFLAGS += -I. -DHAVE_SYSTEMD_SOCKET_SUPPORT='$(HAVE_SYSTEMD_SOCKET_SUPPORT)'
 
 bin_PROGRAMS = gencore
-gencore_SOURCES = coredump.c proc.c
+gencore_SOURCES = coredump.c proc.c elf32.c elf64.c
 
diff --git a/src/coredump.c b/src/coredump.c
index f9c7176..b1ee99d 100644
--- a/src/coredump.c
+++ b/src/coredump.c
@@ -28,6 +28,7 @@
 #include <stdlib.h>
 #include <dirent.h>
 #include <errno.h>
+#include <elf.h>
 #include <sys/ptrace.h>
 #include <coredump.h>
 
@@ -193,6 +194,14 @@ int do_coredump(int pid, char *core_file)
 	if (ret == -1)
 		goto cleanup;
 
+	/* Do elf_dump */
+	if (cp.elf_class == ELFCLASS32)
+		ret = do_elf32_coredump(pid, &cp);
+	else
+		ret = do_elf64_coredump(pid, &cp);
+	if (ret)
+		goto cleanup;
+
 cleanup:
 
 	/* Release the threads */
diff --git a/src/elf.c b/src/elf.c
new file mode 100644
index 0000000..280df13
--- /dev/null
+++ b/src/elf.c
@@ -0,0 +1,31 @@
+/*
+ * ELF helper routines for gencore
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2013
+ *
+ * Authors:
+ *      Janani Venkataraman <jananve@...ibm.com>
+ *      Suzuki K. Poulose <suzuki@...ibm.com>
+ */
+
+#include <stdio.h>
+#include "coredump.h"
+
+int do_elf_coredump(int pid, struct core_proc *cp)
+{
+	return 0;
+}
diff --git a/src/elf32.c b/src/elf32.c
new file mode 100644
index 0000000..d6b40b4
--- /dev/null
+++ b/src/elf32.c
@@ -0,0 +1,33 @@
+/*
+ * ELF helper routines for gencore
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2013
+ *
+ * Authors:
+ *      Janani Venkataraman <jananve@...ibm.com>
+ */
+
+/*
+ * We include elf.c to add all the elf specific operations here.
+ * In this file, we define all 32 bit specific data and hence
+ * this file would contain all elf 32 bit specific functions
+ * and operations once elf.c is included.
+ */
+
+#define do_elf_coredump do_elf32_coredump
+
+#include "elf.c"
diff --git a/src/elf64.c b/src/elf64.c
new file mode 100644
index 0000000..d8b5e89
--- /dev/null
+++ b/src/elf64.c
@@ -0,0 +1,33 @@
+/*
+ * ELF helper routines for gencore
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) IBM Corporation, 2013
+ *
+ * Authors:
+ *      Janani Venkataraman <jananve@...ibm.com>
+ */
+
+/*
+ * We include elf.c to add all the elf specific operations here.
+ * In this file, we define all 64 bit specific data and hence
+ * this file would contain all elf 64 bit specific functions
+ * and operations once elf.c is included.
+ */
+
+#define do_elf_coredump do_elf64_coredump
+
+#include "elf.c"

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