rk: revert to v3.10
[firefly-linux-kernel-4.4.55.git] / arch / um / kernel / trap.c
index 06ab0ebe0a0f39915df14044ac676ef2c9ebf546..089f3987e273a2c3f9576ef923dbd8ba8648cca5 100644 (file)
@@ -30,7 +30,8 @@ int handle_page_fault(unsigned long address, unsigned long ip,
        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;
 
@@ -41,8 +42,6 @@ int handle_page_fault(unsigned long address, unsigned long ip,
        if (in_atomic())
                goto out_nosemaphore;
 
-       if (is_user)
-               flags |= FAULT_FLAG_USER;
 retry:
        down_read(&mm->mmap_sem);
        vma = find_vma(mm, address);
@@ -59,15 +58,12 @@ retry:
 
 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;
@@ -80,8 +76,6 @@ good_area:
                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;
@@ -130,8 +124,6 @@ out_of_memory:
         * (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;
 }