vmalloc does not allocate a vm_struct for vm_map_ram() areas. That causes us to deny usercopies from those areas. This affects XFS which uses vm_map_ram() for its directories. Fix this by calling find_vmap_area() instead of find_vm_area().
Unified · Split
| @@ -215,6 +215,7 @@ extern struct vm_struct *__get_vm_area_caller(unsigned long size, · 214 unmodified lines | |||
| 215 | void free_vm_area(struct vm_struct *area); | 215 | void free_vm_area(struct vm_struct *area); |
| 216 | extern struct vm_struct *remove_vm_area(const void *addr); | 216 | extern struct vm_struct *remove_vm_area(const void *addr); |
| 217 | extern struct vm_struct *find_vm_area(const void *addr); | 217 | extern struct vm_struct *find_vm_area(const void *addr); |
| 218 | struct vmap_area *find_vmap_area(unsigned long addr); | ||
| 218 | 219 | ||
| 219 | static inline bool is_vm_area_hugepages(const void *addr) | 220 | static inline bool is_vm_area_hugepages(const void *addr) |
| 220 | { | 221 | { |
| @@ -173,16 +173,14 @@ static inline void check_heap_object(const void *ptr, unsigned long n, · 172 unmodified lines | |||
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | if (is_vmalloc_addr(ptr)) { | 175 | if (is_vmalloc_addr(ptr)) { |
| 176 | struct vm_struct *area = find_vm_area(ptr); | 176 | struct vmap_area *area = find_vmap_area((unsigned long)ptr); |
| 177 | unsigned long offset; | 177 | unsigned long offset; |
| 178 | 178 | ||
| 179 | if (!area) { | 179 | if (!area) |
| 180 | usercopy_abort("vmalloc", "no area", to_user, 0, n); | 180 | usercopy_abort("vmalloc", "no area", to_user, 0, n); |
| 181 | return; | ||
| 182 | } | ||
| 183 | 181 | ||
| 184 | offset = ptr - area->addr; | 182 | offset = (unsigned long)ptr - area->va_start; |
| 185 | if (offset + n > get_vm_area_size(area)) | 183 | if ((unsigned long)ptr + n > area->va_end) |
| 186 | usercopy_abort("vmalloc", NULL, to_user, offset, n); | 184 | usercopy_abort("vmalloc", NULL, to_user, offset, n); |
| 187 | return; | 185 | return; |
| 188 | } | 186 | } |
| @@ -1798,7 +1798,7 @@ static void free_unmap_vmap_area(struct vmap_area *va) · 1797 unmodified lines | |||
| 1798 | free_vmap_area_noflush(va); | 1798 | free_vmap_area_noflush(va); |
| 1799 | } | 1799 | } |
| 1800 | 1800 | ||
| 1801 | static struct vmap_area *find_vmap_area(unsigned long addr) | 1801 | struct vmap_area *find_vmap_area(unsigned long addr) |
| 1802 | { | 1802 | { |
| 1803 | struct vmap_area *va; | 1803 | struct vmap_area *va; |
| 1804 | 1804 | ||