Skip to content

Commit 47da297

Browse files
jmberg-intelrichardweinberger
authored andcommitted
um: mm: check more comprehensively for stub changes
If userspace tries to change the stub, we need to kill it, because otherwise it can escape the virtual machine. In a few cases the stub checks weren't good, e.g. if userspace just tries to mmap(0x100000 - 0x1000, 0x3000, ...) it could succeed to get a new private/anonymous mapping replacing the stubs. Fix this by checking everywhere, and checking for _overlap_, not just direct changes. Cc: stable@vger.kernel.org Fixes: 3963333 ("uml: cover stubs with a VMA") Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent e1e22d0 commit 47da297

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

‎arch/um/kernel/tlb.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,9 @@ static int add_mmap(unsigned long virt, unsigned long phys, unsigned long len,
125125
struct host_vm_op *last;
126126
int fd = -1, ret = 0;
127127

128+
if (virt + len > STUB_START && virt < STUB_END)
129+
return -EINVAL;
130+
128131
if (hvc->userspace)
129132
fd = phys_mapping(phys, &offset);
130133
else
@@ -162,7 +165,7 @@ static int add_munmap(unsigned long addr, unsigned long len,
162165
struct host_vm_op *last;
163166
int ret = 0;
164167

165-
if ((addr >= STUB_START) && (addr < STUB_END))
168+
if (addr + len > STUB_START && addr < STUB_END)
166169
return -EINVAL;
167170

168171
if (hvc->index != 0) {
@@ -192,6 +195,9 @@ static int add_mprotect(unsigned long addr, unsigned long len,
192195
struct host_vm_op *last;
193196
int ret = 0;
194197

198+
if (addr + len > STUB_START && addr < STUB_END)
199+
return -EINVAL;
200+
195201
if (hvc->index != 0) {
196202
last = &hvc->ops[hvc->index - 1];
197203
if ((last->type == MPROTECT) &&
@@ -472,6 +478,10 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long address)
472478
struct mm_id *mm_id;
473479

474480
address &= PAGE_MASK;
481+
482+
if (address >= STUB_START && address < STUB_END)
483+
goto kill;
484+
475485
pgd = pgd_offset(mm, address);
476486
if (!pgd_present(*pgd))
477487
goto kill;

0 commit comments

Comments
 (0)