Messages in this thread Patch in this message | | | Subject | Re: [PATCH] sys_remap_file_pages: fix ->vm_file accounting | From | Miklos Szeredi <> | Date | Wed, 30 Jan 2008 17:55:01 +0100 |
| |
On Wed, 2008-01-30 at 17:20 +0300, Oleg Nesterov wrote: > Fix ->vm_file accounting, mmap_region() may do do_munmap().
Ouch! I didn't think of that case at all...
There's a small problem with the patch: the vma itself is freed at unmap, so the fput(vma->vm_file) may crash. Here's an updated patch.
Thanks for spotting this!
Miklos ----
From: Oleg Nesterov <oleg@tv-sign.ru>
Fix ->vm_file accounting, mmap_region() may do do_munmap().
Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> ---
Index: linux/mm/fremap.c =================================================================== --- linux.orig/mm/fremap.c 2008-01-17 19:00:17.000000000 +0100 +++ linux/mm/fremap.c 2008-01-30 17:47:27.000000000 +0100 @@ -190,10 +190,13 @@ asmlinkage long sys_remap_file_pages(uns */ if (mapping_cap_account_dirty(mapping)) { unsigned long addr; + struct file *file = vma->vm_file; flags &= MAP_NONBLOCK; - addr = mmap_region(vma->vm_file, start, size, + get_file(file); + addr = mmap_region(file, start, size, flags, vma->vm_flags, pgoff, 1); + fput(file); if (IS_ERR_VALUE(addr)) { err = addr; } else {
| |