linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Reimplement old functionality of vm_munmap to vm_munmap_mm
@ 2013-11-19 16:29 James Custer
  2013-11-19 16:31 ` Christoph Hellwig
  2013-11-19 17:04 ` Al Viro
  0 siblings, 2 replies; 3+ messages in thread
From: James Custer @ 2013-11-19 16:29 UTC (permalink / raw)
  To: linux-mm
  Cc: Rik van Riel, Mel Gorman, Kirill A. Shutemov, Jiang Liu,
	Michel Lespinasse, Hugh Dickins, Oleg Nesterov, Al Viro,
	linux-kernel, James Custer

Commit bfce281c287a427d0841fadf5d59242757b4e620 killed the mm parameter to
vm_munmap. Although the mm parameter was not used in any in-tree kernel
modules, it is used by some out-of-tree modules.

We create a new function vm_munmap_mm that has the same functionality as
vm_munmap, whereas vm_munmap uses current->mm, vm_munmap_mm takes the mm as
a paramter.

Since this is a newly exported symbol it is marked EXPORT_SYMBOL_GPL.
---
 include/linux/mm.h | 1 +
 mm/mmap.c          | 9 +++++++--
 mm/nommu.c         | 9 +++++++--
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0548eb2..6e9917e 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1724,6 +1724,7 @@ static inline void mm_populate(unsigned long addr, unsigned long len) {}
 /* These take the mm semaphore themselves */
 extern unsigned long vm_brk(unsigned long, unsigned long);
 extern int vm_munmap(unsigned long, size_t);
+extern int vm_munmap_mm(struct mm_struct *, unsigned long, size_t);
 extern unsigned long vm_mmap(struct file *, unsigned long,
         unsigned long, unsigned long,
         unsigned long, unsigned long);
diff --git a/mm/mmap.c b/mm/mmap.c
index 834b2d7..63eb96e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2539,16 +2539,21 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
 	return 0;
 }
 
-int vm_munmap(unsigned long start, size_t len)
+int vm_munmap_mm(struct mm_struct *mm, unsigned long start, size_t len)
 {
 	int ret;
-	struct mm_struct *mm = current->mm;
 
 	down_write(&mm->mmap_sem);
 	ret = do_munmap(mm, start, len);
 	up_write(&mm->mmap_sem);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(vm_munmap_mm);
+
+int vm_munmap(unsigned long start, size_t len)
+{
+	return vm_munmap_mm(current->mm, start, len);
+}
 EXPORT_SYMBOL(vm_munmap);
 
 SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
diff --git a/mm/nommu.c b/mm/nommu.c
index fec093a..5cf8677 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -1717,9 +1717,8 @@ erase_whole_vma:
 }
 EXPORT_SYMBOL(do_munmap);
 
-int vm_munmap(unsigned long addr, size_t len)
+int vm_munmap_mm(struct mm_struct *mm, unsigned long addr, size_t len)
 {
-	struct mm_struct *mm = current->mm;
 	int ret;
 
 	down_write(&mm->mmap_sem);
@@ -1727,6 +1726,12 @@ int vm_munmap(unsigned long addr, size_t len)
 	up_write(&mm->mmap_sem);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(vm_munmap_mm);
+
+int vm_munmap(unsigned long addr, size_t len)
+{
+	return vm_munmap_mm(current->mm, addr, len);
+}
 EXPORT_SYMBOL(vm_munmap);
 
 SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Reimplement old functionality of vm_munmap to vm_munmap_mm
  2013-11-19 16:29 [PATCH] Reimplement old functionality of vm_munmap to vm_munmap_mm James Custer
@ 2013-11-19 16:31 ` Christoph Hellwig
  2013-11-19 17:04 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2013-11-19 16:31 UTC (permalink / raw)
  To: James Custer
  Cc: linux-mm, Rik van Riel, Mel Gorman, Kirill A. Shutemov,
	Jiang Liu, Michel Lespinasse, Hugh Dickins, Oleg Nesterov,
	Al Viro, linux-kernel

On Tue, Nov 19, 2013 at 10:29:52AM -0600, James Custer wrote:
> Commit bfce281c287a427d0841fadf5d59242757b4e620 killed the mm parameter to
> vm_munmap. Although the mm parameter was not used in any in-tree kernel
> modules, it is used by some out-of-tree modules.

Which doesn't matter at all.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Reimplement old functionality of vm_munmap to vm_munmap_mm
  2013-11-19 16:29 [PATCH] Reimplement old functionality of vm_munmap to vm_munmap_mm James Custer
  2013-11-19 16:31 ` Christoph Hellwig
@ 2013-11-19 17:04 ` Al Viro
  1 sibling, 0 replies; 3+ messages in thread
From: Al Viro @ 2013-11-19 17:04 UTC (permalink / raw)
  To: James Custer
  Cc: linux-mm, Rik van Riel, Mel Gorman, Kirill A. Shutemov,
	Jiang Liu, Michel Lespinasse, Hugh Dickins, Oleg Nesterov,
	linux-kernel

On Tue, Nov 19, 2013 at 10:29:52AM -0600, James Custer wrote:
> Commit bfce281c287a427d0841fadf5d59242757b4e620 killed the mm parameter to
> vm_munmap. Although the mm parameter was not used in any in-tree kernel
> modules, it is used by some out-of-tree modules.
> 
> We create a new function vm_munmap_mm that has the same functionality as
> vm_munmap, whereas vm_munmap uses current->mm, vm_munmap_mm takes the mm as
> a paramter.
> 
> Since this is a newly exported symbol it is marked EXPORT_SYMBOL_GPL.

Which modules and what are they doing with it?  More to the point,
what prevents races with e.g. dumping core?  And that's not an idle
question - for example, fs/aio.c used to contain very unpleasant
races of that kind exactly because it was playing games with modifying
->mm other than current->mm.

In other words, NAK.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-11-19 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-19 16:29 [PATCH] Reimplement old functionality of vm_munmap to vm_munmap_mm James Custer
2013-11-19 16:31 ` Christoph Hellwig
2013-11-19 17:04 ` Al Viro

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).