mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Breno" <brenosp@brasilsec.com.br>
To: "Kernel List" <linux-kernel@vger.kernel.org>
Subject: [PATCH] 2.4.22 fs/exec
Date: Wed, 26 Nov 2003 19:31:51 -0200	[thread overview]
Message-ID: <001201c3b465$8e979060$34dfa7c8@bsb.virtua.com.br> (raw)

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

                 reply	other threads:[~2003-11-26 21:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='001201c3b465$8e979060$34dfa7c8@bsb.virtua.com.br' \
    --to=brenosp@brasilsec.com.br \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®