Skip to contentSkip to conversation

New do_mremap vulnerabitily.

DISCUSSION Raphael Rigo 4 participants 6 messages Feb 18, 2004

lore
Share & tools
lore
#2 lore raw
Quoted 2 lines · Linus Torvalds

Fixed in 2.6.3 and 2.4.25 (and, I think, vendor kernels), please upgrade if you allow local shell access to untrusted users.

There is still a call to do_munmap() that does not check the return code, called from move_vma(), which in turn is called in do_mremap().

Can that call ever fail and cause Bad Things to happen?

If we know that its never going to fail, it might be useful to have a comment explaining it so we don't open up more exploits in the future.

Chris

Signature · 4 lines
Chris Friesen                    | MailStop: 043/33/F10
Nortel Networks                  | work: (613) 765-0557
3500 Carling Avenue              | fax:  (613) 765-2986
Nepean, ON K2H 8E9 Canada        | email: [email protected]
#3 lore raw
Quoted 5 lines · Chris Friesen

There is still a call to do_munmap() that does not check the return code, called from move_vma(), which in turn is called in do_mremap().

Can that call ever fail and cause Bad Things to happen?

Yes it can fail, and no, bad things can't happen. We could return the error code to user space, but on the other hand, by the time the munmap fails we would already have done 90% of the mremap(), so it doesn't much help user space to know that the old area still has a vma, but no pages associated with it.

Linus

#4 lore raw
Quoted 7 lines · Linus Torvalds
Quoted 4 lines · Chris Friesen

There is still a call to do_munmap() that does not check the return code, called from move_vma(), which in turn is called in do_mremap().

Quoted 7 lines
Quoted 1 line

Can that call ever fail and cause Bad Things to happen?

Yes it can fail, and no, bad things can't happen. We could return the error code to user space, but on the other hand, by the time the munmap fails we would already have done 90% of the mremap(), so it doesn't much help user space to know that the old area still has a vma, but no pages associated with it.

which is a bug, mremap has to retire fully and it's not doing that (obviously we don't want to write a retirement logic, we only want to preallocate whatever needed so we don't need to retire), but it's not a bad bug, since it only matters for real apps, an real apps will only fall into this do_munamp due the oom condition, which isn't going to trigger in do_munmap anyways, and even in the unlikely case that it does it is extremly unlikely to generate an exploitable hole in the real (non malicious) app.

#5 lore raw
In reply to Chris Friesen
Quoted 9 lines · Chris Friesen
Quoted 2 lines · Linus Torvalds

Fixed in 2.6.3 and 2.4.25 (and, I think, vendor kernels), please upgrade if you allow local shell access to untrusted users.

There is still a call to do_munmap() that does not check the return code, called from move_vma(), which in turn is called in do_mremap().

Can that call ever fail and cause Bad Things to happen?

it shouldn't cause bad things, it may generate a corrupt address space from userspace point of view (the original vma will be stil there), but it's like if you did one more mmap, so it's only a problem if you can drive the app to buffer overflow or something like that because of this corrupted address space. So it's only an userspace issue with real apps, and with real apps the only thing that can make munamp fail is an oom which is near to impossible for you to oom the app exactly in this do_munmap call, the by far highest probability is that the first oom will happen in the page faults, not in the syscalls.

Quoted 2 lines

If we know that its never going to fail, it might be useful to have a comment explaining it so we don't open up more exploits in the future.

the whole code needs a revamp for example for when the pagetables cannot be allocated and the merging isn't retired (similar problem to the do_munmap you mentioned above and there are other issues like that), mremap simply isn't retiring correctly in presence of oom errors, that's only an userspace issue, no way to exploit the kernel with that, we've to fix it for 2.6 to provide perfect retirement from oom (basically only a pratical matter with full overcommit but anyways). For 2.4 where the thing will go in production the next day, going with the bandaid from Solar was the simplest and in turn safest solution without risk of regression.