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:	Tue, 14 Dec 2010 15:43:44 +0530
From:	"Suzuki K. Poulose" <suzuki@...ibm.com>
To:	linux-kernel@...r.kernel.org
Cc:	"Suzuki K. Poulose" <suzuki@...ibm.com>,
	Jeremy Fitzhardinge <jeremy.fitzhardinge@...rix.com>,
	Christoph Hellwig <hch@....de>,
	Masami Hiramatsu <mhiramat@...hat.com>,
	Ananth N Mavinakayanahalli <ananth@...ibm.com>,
	Daisuke HATAYAMA <d.hatayama@...fujitsu.com>,
	Andi Kleen <andi@...stfloor.org>,
	Roland McGrath <roland@...hat.com>,
	Amerigo Wang <amwang@...hat.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@...fujitsu.com>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Oleg Nesterov <oleg@...hat.com>,
	Andrew Morton <akpm@...ux-foundation.org>
Subject: [Patch 12/21] Check if the process is an ELF executable

Validate if the process is an ELF exec. This will be later extended to identify 
if the task is a native ELF or a compat ELF.

Signed-off-by: Suzuki K. Poulose <suzuki@...ibm.com>
---
 fs/proc/gencore.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

Index: linux-2.6.36-rc7/fs/proc/gencore.c
===================================================================
--- linux-2.6.36-rc7.orig/fs/proc/gencore.c
+++ linux-2.6.36-rc7/fs/proc/gencore.c
@@ -23,6 +23,8 @@
  */
 
 #include <linux/seq_file.h>
+#include <linux/elf.h>
+
 #include "internal.h"
 #include "gencore.h"
 
@@ -85,6 +87,30 @@ static int release_gencore(struct inode 
 }
 
 /*
+ * Determine whether the task is an ELF executable.
+ * Returns
+ * 	< 0	- Non-ELF
+ * 	0 	- Native ELF Executable
+ */
+static int get_elf_class(struct task_struct *task)
+{
+	struct elfhdr hdr;
+	int ret = 0;
+
+	ret = kernel_read(task->mm->exe_file, 0, (char*)&hdr, sizeof(hdr));
+	if (ret < 0)
+		return ret;
+
+	/* Verify the ELF magic on the exe_file */
+	if (memcmp(hdr.e_ident, ELFMAG, SELFMAG))
+		return -EINVAL;
+	if (elf_check_arch(&hdr))
+		return 0;
+
+	return -EINVAL;
+}
+
+/*
  * Validate if the call is valid. We also need to prevent >1 open
  * of the same file.
  */
@@ -93,10 +119,15 @@ static int open_gencore(struct inode *in
 	struct task_struct *task = get_proc_task(inode);
 	struct core_proc *cp;
 	int ret = 0;
+	int elf_class;
 
 	if (!task)
 		return -ENOENT;
 
+	elf_class = get_elf_class(task);
+	if (elf_class < 0)
+		return elf_class;
+
 	mutex_lock(&core_mutex);
 	cp = get_core_proc(task);
 	if (cp) {
--
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