Revert "sparc64: Fix __copy_{to,from}_user_inatomic defines."
[firefly-linux-kernel-4.4.55.git] / arch / s390 / lib / uaccess_pt.c
index 466fb3383960442b7624e51990536d2cf0b8c65d..1bf40ef57cf6165c45336e2579799844af92ec1d 100644 (file)
@@ -78,27 +78,33 @@ static size_t copy_in_kernel(size_t count, void __user *to,
  * contains the (negative) exception code.
  */
 #ifdef CONFIG_64BIT
+
 static unsigned long follow_table(struct mm_struct *mm,
                                  unsigned long address, int write)
 {
        unsigned long *table = (unsigned long *)__pa(mm->pgd);
 
+       if (unlikely(address > mm->context.asce_limit - 1))
+               return -0x38UL;
        switch (mm->context.asce_bits & _ASCE_TYPE_MASK) {
        case _ASCE_TYPE_REGION1:
                table = table + ((address >> 53) & 0x7ff);
                if (unlikely(*table & _REGION_ENTRY_INV))
                        return -0x39UL;
                table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
+               /* fallthrough */
        case _ASCE_TYPE_REGION2:
                table = table + ((address >> 42) & 0x7ff);
                if (unlikely(*table & _REGION_ENTRY_INV))
                        return -0x3aUL;
                table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
+               /* fallthrough */
        case _ASCE_TYPE_REGION3:
                table = table + ((address >> 31) & 0x7ff);
                if (unlikely(*table & _REGION_ENTRY_INV))
                        return -0x3bUL;
                table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN);
+               /* fallthrough */
        case _ASCE_TYPE_SEGMENT:
                table = table + ((address >> 20) & 0x7ff);
                if (unlikely(*table & _SEGMENT_ENTRY_INV))