forked fromtorvalds/linux
- Notifications
You must be signed in to change notification settings - Fork1
Commit63489f8
hugetlbfs: check for pgoff value overflow
A vma with vm_pgoff large enough to overflow a loff_t type whenconverted to a byte offset can be passed via the remap_file_pages systemcall. The hugetlbfs mmap routine uses the byte offset to calculatereservations and file size.A sequence such as: mmap(0x20a00000, 0x600000, 0, 0x66033, -1, 0); remap_file_pages(0x20a00000, 0x600000, 0, 0x20000000000000, 0);will result in the following when task exits/file closed, kernel BUG at mm/hugetlb.c:749! Call Trace: hugetlbfs_evict_inode+0x2f/0x40 evict+0xcb/0x190 __dentry_kill+0xcb/0x150 __fput+0x164/0x1e0 task_work_run+0x84/0xa0 exit_to_usermode_loop+0x7d/0x80 do_syscall_64+0x18b/0x190 entry_SYSCALL_64_after_hwframe+0x3d/0xa2The overflowed pgoff value causes hugetlbfs to try to set up a mappingwith a negative range (end < start) that leaves invalid state whichcauses the BUG.The previous overflow fix to this code was incomplete and did not takethe remap_file_pages system call into account.[mike.kravetz@oracle.com: v3] Link:http://lkml.kernel.org/r/20180309002726.7248-1-mike.kravetz@oracle.com[akpm@linux-foundation.org: include mmdebug.h][akpm@linux-foundation.org: fix -ve left shift count on sh]Link:http://lkml.kernel.org/r/20180308210502.15952-1-mike.kravetz@oracle.comFixes:045c7a3 ("hugetlbfs: fix offset overflow in hugetlbfs mmap")Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>Reported-by: Nic Losby <blurbdust@gmail.com>Acked-by: Michal Hocko <mhocko@suse.com>Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>Cc: Yisheng Xie <xieyisheng1@huawei.com>Cc: <stable@vger.kernel.org>Signed-off-by: Andrew Morton <akpm@linux-foundation.org>Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent2e517d6 commit63489f8
2 files changed
+21
-3
lines changedOriginal file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
111 | 121 |
| |
112 | 122 |
| |
113 | 123 |
| |
| |||
127 | 137 |
| |
128 | 138 |
| |
129 | 139 |
| |
130 |
| - | |
131 |
| - | |
| 140 | + | |
| 141 | + | |
132 | 142 |
| |
133 |
| - | |
| 143 | + | |
134 | 144 |
| |
135 | 145 |
| |
| 146 | + | |
136 | 147 |
| |
137 | 148 |
| |
138 | 149 |
| |
|
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18 | 18 |
| |
19 | 19 |
| |
20 | 20 |
| |
| 21 | + | |
21 | 22 |
| |
22 | 23 |
| |
23 | 24 |
| |
| |||
4374 | 4375 |
| |
4375 | 4376 |
| |
4376 | 4377 |
| |
| 4378 | + | |
| 4379 | + | |
| 4380 | + | |
| 4381 | + | |
| 4382 | + | |
| 4383 | + | |
4377 | 4384 |
| |
4378 | 4385 |
| |
4379 | 4386 |
| |
|
0 commit comments
Comments
(0)