LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] 2.4.22 fs/exec
@ 2003-11-26 21:31 Breno
  0 siblings, 0 replies; only message in thread
From: Breno @ 2003-11-26 21:31 UTC (permalink / raw)
  To: Kernel List

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: exec.patch --]
[-- Type: application/octet-stream, Size: 3041 bytes --]

--- exec-original.c	Tue Oct 14 16:40:12 2003
+++ exec.c	Wed Oct 15 22:26:58 2003
@@ -39,6 +39,8 @@
 #include <linux/utsname.h>
 #define __NO_VERSION__
 #include <linux/module.h>
+#include <linux/mm.h>
+#include <linux/sched.h>
 
 #include <asm/uaccess.h>
 #include <asm/pgalloc.h>
@@ -1097,6 +1099,87 @@
 	*out_ptr = 0;
 }
 
+
+int show_addrvm(struct vm_area_struct *vma, struct task_struct *task, struct pt_regs *regs)
+{
+    struct vm_area_struct *next, *mlloc, *stk;
+    unsigned long addr, end;
+
+		
+		addr = vma->vm_start;
+		
+		end = vma->vm_end;
+		    
+		    printk(KERN_CRIT"Process name %s\n",task->comm);
+		    printk(KERN_CRIT"Process PID %d\n",task->pid);
+		    printk(KERN_CRIT"Process REGS\n");
+		    printk(KERN_CRIT"ebp :0x%x\n",regs->ebp);
+		    printk(KERN_CRIT"eax : 0x%x\n",regs->eax);
+		    printk(KERN_CRIT"eip : 0x%x\n",regs->eip);
+		    printk(KERN_CRIT"esp : 0x%x\n",regs->esp);
+		
+		    stk = find_vma(task->mm,task->mm->start_stack);
+		    
+		    if(stk)
+		    {
+			printk(KERN_CRIT"Process stack area start : 0x%x\n",stk->vm_start);
+			printk(KERN_CRIT"Stack flags 0x%x\n",stk->vm_flags);
+		    }
+		    
+		    mlloc = find_vma(task->mm,task->mm->start_brk);
+		    
+		    if(mlloc)
+		    {
+			printk(KERN_CRIT"Process brk area range: 0x%x - 0x%x \n",mlloc->vm_start, mlloc->vm_end);
+			printk(KERN_CRIT"brk flags 0x%x\n",mlloc->vm_flags);
+		    }
+		    
+		    do 
+		    {
+		    
+			printk(KERN_CRIT" VM Range 0x%x - 0x%x\n",addr,end);
+			printk(KERN_CRIT" VM flags 0x%x\n",vma->vm_flags);
+		    
+			if(vma->vm_file)
+			{
+			    printk(KERN_CRIT" VM map file : %s\n",vma->vm_file->f_dentry->d_name.name);
+			}
+		    
+			next = vma->vm_next;
+
+			vma = next;
+		    
+			addr = vma->vm_start;
+		    
+			end = vma->vm_end;
+		    
+		    }while((vma->vm_next) && (vma));
+
+return 0;
+}
+
+
+int print_vm_state(struct pt_regs *regs)
+{
+	struct task_struct *pold = NULL;
+	int show , name;
+
+
+	for_each_task(pold)
+	{
+		
+	    if((pold != NULL) && (pold->mm != NULL) && (pold->comm != pold->prev_task->comm))
+	    {
+		
+	    show = show_addrvm(pold->mm->mmap, pold, regs);
+	    
+	    }
+	    
+	}
+	
+return 0;
+}
+
 int do_coredump(long signr, struct pt_regs * regs)
 {
 	struct linux_binfmt * binfmt;
@@ -1104,8 +1187,11 @@
 	struct file * file;
 	struct inode * inode;
 	int retval = 0;
-
+	int retstate;
+	struct task_struct *p = current;
+	
 	lock_kernel();
+	
 	binfmt = current->binfmt;
 	if (!binfmt || !binfmt->core_dump)
 		goto fail;
@@ -1133,12 +1219,16 @@
 		goto close_fail;
 	if (do_truncate(file->f_dentry, 0) != 0)
 		goto close_fail;
-
+		
+	printk(KERN_CRIT"Core dump created of process pid %d\n",p->pid);
+	
 	retval = binfmt->core_dump(signr, regs, file);
+	
+	retstate = print_vm_state(regs);
 
 close_fail:
 	filp_close(file, NULL);
 fail:
 	unlock_kernel();
 	return retval;
-}
+}
\ No newline at end of file

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-11-26 21:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-26 21:31 [PATCH] 2.4.22 fs/exec Breno

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