pmd_t *pmd;
pte_t *pte;
int err = -EFAULT;
- unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
+ unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
+ (is_write ? FAULT_FLAG_WRITE : 0);
*code_out = SEGV_MAPERR;
if (in_atomic())
goto out_nosemaphore;
- if (is_user)
- flags |= FAULT_FLAG_USER;
retry:
down_read(&mm->mmap_sem);
vma = find_vma(mm, address);
good_area:
*code_out = SEGV_ACCERR;
- if (is_write) {
- if (!(vma->vm_flags & VM_WRITE))
- goto out;
- flags |= FAULT_FLAG_WRITE;
- } else {
- /* Don't require VM_READ|VM_EXEC for write faults! */
- if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
- goto out;
- }
+ if (is_write && !(vma->vm_flags & VM_WRITE))
+ goto out;
+
+ /* Don't require VM_READ|VM_EXEC for write faults! */
+ if (!is_write && !(vma->vm_flags & (VM_READ | VM_EXEC)))
+ goto out;
do {
int fault;
if (unlikely(fault & VM_FAULT_ERROR)) {
if (fault & VM_FAULT_OOM) {
goto out_of_memory;
- } else if (fault & VM_FAULT_SIGSEGV) {
- goto out;
} else if (fault & VM_FAULT_SIGBUS) {
err = -EACCES;
goto out;
* (which will retry the fault, or kill us if we got oom-killed).
*/
up_read(&mm->mmap_sem);
- if (!is_user)
- goto out_nosemaphore;
pagefault_out_of_memory();
return 0;
}