Re: Question on page fault handler and hijacking it

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

 



On 8/23/05, Vincenzo Mallozzi <vinjunior@xxxxxxxx> wrote:
> Hi all,
> as I've already described in other mails, I'm hijacking the page fault handler
> function. All works well but there's a little problem.
> To show the problem, I post the code of my handler with I replace the original
> handler.
> 
> 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.

regards,
-Gaurav

> 16.             hijack = 1;
> 17.     }
> 
> 18.     if (hijack != 1)
> 19.             (*mtpmc_old_int_handler)(regs,error_code);
> 
> 20.     return;
> 21. }
> 
> Note the line 14 and 15. These lines, respectively, make the page at the given
> address first as writable and then as not writable. The result should be the
> same by deleting them and let the page that cause page fault remain not
> writable.
> But if I delete lines 14 and 15,, in the moment of a page fault the system
> blocks. If I don't delete them, instead, all works very well.
> I don't understand why it happens.
> Vincenzo Mallozzi,
> 
> 
> 
> 
> 
> ___________________________________
> 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/
> 
>

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