Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nested page-faulting of user-space address in Linux

I would like to know if it is functionally wrong to page-fault a user-space address when kernel is running fault-handler to bring in a user-page.

OS is Linux 2.6.30

Assume that both user-addresses are valid ( falling within vma , rw permission ) for the task.

When I check the kernel code, i find that the kernel does not mind the nested fault if the faulted-addresses are valid and the fault did not occur in atomic-context or in irq handler.

(I dont think the answer is cpu-specific, but I would add that i am interested in arm and mips ).

eg : The scenario can happen if I print stack-data from page-fault handler.

like image 819
shankar Avatar asked Mar 19 '10 13:03

shankar


1 Answers

Looking through kernel sources for the last hour suggests that it is fine: Neither the definition of struct vm_operations_struct nor the code between handle_mm_fault() and the call to vma->vm_ops->fault in __do_fault() has any cautionary statements about this, and the few ->fault handlers I looked at didn't seem worried about it either...

... I think the main thing is that you need to avoid going into an infinite recursion by faulting on the same address again, but that would presumably only happen if the kernel stack was in your vma, which is most likely not going to be happen?

like image 147
SamB Avatar answered Oct 27 '22 19:10

SamB