Re: Problem with LIST_HEAD and list_add (was Page Fault Handler Hijacking and Oops)

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

 



On Thu, Aug 04, 2005 at 22:29:45 +0000, Vincenzo Mallozzi wrote:
> [...]
>  1.  void mtpmc_set_mm_not_writable(struct mm_struct *mm)
>  2.  {
>  3.   struct vm_area_struct *vm;
>  4.   struct mtpmc_wrprotected_pages *wr_page, *temp_page_wr;
>  5.   struct mtpmc_vm_wrprotected *temp_vma_wr;
>  6.   struct page *page;
>  7.   pte_t *pte;
>  8.   unsigned long addr;
>  9.  
> 10.   down_write(&mm->mmap_sem);
> 11.   for (vm = mm->mmap; vm!=NULL; vm=vm->vm_next)
> 12.    if(mtpmc_vm_to_save(mm, vm) == 1){
> 13.     temp_vma_wr = mtpmc_mk_vm_wrprotected(vm);
> 14.     list_add_tail(&temp_vma_wr->list, &vm_write_protected);
> 15.     wr_page = temp_vma_wr->pages;
> 16.     INIT_LIST_HEAD(&wr_page->list);
> 17.     for(addr=vm->vm_start;addr<vm->vm_end;addr+=PAGE_SIZE){
> 18.      pte = mtpmc_get_pte_from_address(mm, addr);
> 19.      if (pte)
> 20.       if (pte_write(*pte)){
> 21.        set_pte(pte, pte_wrprotect(*pte));
> 22.        list_add_tail(&mtpmc_mk_page_wrprotected(addr)->list,   
>              &wr_page->list);
> 23.   }
> 24.    }
> 
> 25.   up_write(&mm->mmap_sem);
> 26.
> 27. return;
> 28.  }

Perhaps your code is safe, but I would think you should have the list
modification itself (list_add_tail) protected by a spin_lock_irqsave.
That's the only way to exclude against interrupts (you can't lock
semaphores in interrupt context).

-------------------------------------------------------------------------------
						 Jan 'Bulb' Hudec <bulb@xxxxxx>

Attachment: signature.asc
Description: Digital signature


[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