lkml.org 
[lkml]   [2008]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] sys_remap_file_pages: fix ->vm_file accounting
From
Date

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 {



\
 
 \ /
  Last update: 2008-01-30 17:57    [W:0.064 / U:2.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site