LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Miklos Szeredi <mszeredi@suse.cz>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	William Lee Irwin III <wli@holomorphy.com>,
	Nick Piggin <nickpiggin@yahoo.com.au>,
	Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org, stable@kernel.org
Subject: Re: [PATCH] sys_remap_file_pages: fix ->vm_file accounting
Date: Wed, 30 Jan 2008 17:55:01 +0100	[thread overview]
Message-ID: <1201712101.31222.22.camel@tucsk.pomaz.szeredi.hu> (raw)
In-Reply-To: <20080130142014.GA2164@tv-sign.ru>


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 {



  reply	other threads:[~2008-01-30 16:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-30 14:20 Oleg Nesterov
2008-01-30 16:55 ` Miklos Szeredi [this message]
2008-01-30 17:26   ` Oleg Nesterov
2008-02-02 20:52     ` Matt Helsley
2008-02-02 21:17     ` Matt Helsley
2008-02-03 18:21       ` Oleg Nesterov
2008-02-06 20:33         ` Hugh Dickins
2008-02-07  0:16           ` Matt Helsley
2008-02-07 16:40             ` Hugh Dickins
2008-02-03 18:29     ` Oleg Nesterov
2008-02-06 20:13       ` Hugh Dickins
2008-02-11 10:15         ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1201712101.31222.22.camel@tucsk.pomaz.szeredi.hu \
    --to=mszeredi@suse.cz \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=nickpiggin@yahoo.com.au \
    --cc=oleg@tv-sign.ru \
    --cc=stable@kernel.org \
    --cc=wli@holomorphy.com \
    --subject='Re: [PATCH] sys_remap_file_pages: fix ->vm_file accounting' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).