From: Joonsoo Kim Date: Thu, 29 Nov 2012 03:18:07 +0000 (+1100) Subject: mm: WARN_ON_ONCE if f_op->mmap() change vma's start address X-Git-Tag: next-20121205~1^2~238 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=373d54c59bc800895f601f32eb9496039117b04b;p=karo-tx-linux.git mm: WARN_ON_ONCE if f_op->mmap() change vma's start address During reviewing the source code, I found a comment which mention that after f_op->mmap(), vma's start address can be changed. I didn't verify that it is really possible, because there are so many f_op->mmap() implementation. But if there are some mmap() which change vma's start address, it is possible error situation, because we already prepare prev vma, rb_link and rb_parent and these are related to original address. So add WARN_ON_ONCE for finding that this situtation really happens. Signed-off-by: Joonsoo Kim Signed-off-by: Andrew Morton --- diff --git a/mm/mmap.c b/mm/mmap.c index f940062c8d4b..9ed3a06242a0 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1488,7 +1488,11 @@ munmap_back: * * Answer: Yes, several device drivers can do it in their * f_op->mmap method. -DaveM + * Bug: If addr is changed, prev, rb_link, rb_parent should + * be updated for vma_link() */ + WARN_ON_ONCE(addr != vma->vm_start); + addr = vma->vm_start; pgoff = vma->vm_pgoff; vm_flags = vma->vm_flags;