Re: Question on page fault handler and hijacking it

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tuesday 23 August 2005 05:59, Gaurav Dhiman wrote:
> > A preliminary statement:
> > mtpmc_old_handler contains the address of the original handler
> > 
> >  1. static asmlinkage void mtpmc_handler(struct pt_regs * regs,long
> >                                                              error_code)
> >  2. {
> >  3.     unsigned long address;
> >  4.     struct task_struct *task;
> >  5.     struct mm_struct *mm;
> > 
> >  6.    pid_t pid = current->pid;
> >  7.    int hijack = 0;
> > 
> >  8.     /* gets the address */
> >  9.    __asm__("movl %%cr2,%0":"=r" (address));
> > 
> > 10.     if (the error is a writing error on one of the pages that we've 
setted
> >                as not writable)
> > 11.     {
> > 12.             printk(KERN_DEBUG "page fault handling\n");
> > 13.             send_sig(SIGSTOP, current, 1);
> > 14.             mtpmc_restore_page_writable(current->mm, address);
> > 15.             mtpmc_restore_page_not_writable(current->mm, address);
> 
> for this, its important to know what exactly you are doing in these
> two function, can you paste the code of these functions, I think these
> are function of your module.

Oh yes. I'm sorry. I've not posted the two functions.
These are listed below.
Vincenzo.


void mtpmc_restore_page_not_writable(struct mm_struct *mm, unsigned long addr) 
{
    pte_t *pte;


    pte = mtpmc_get_pte_from_address(mm, addr);
    if (pte != NULL)
            if (pte_write(*pte))
                set_pte(pte, pte_wrprotect(*pte));

    return;
}

void mtpmc_restore_page_writable(struct mm_struct *mm, unsigned long addr) 
{
    pte_t *pte;

        pte = mtpmc_get_pte_from_address(mm, addr);
        if (pte != NULL)
            if (!pte_write(*pte))
                set_pte(pte, pte_mkwrite(*pte));
 
    return;
}



mtpmc_get_pte_from_address return the pointer to pte related to the page with 
given address.

	

	
		
___________________________________ 
Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB 
http://mail.yahoo.it


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux