GIT: unionfs2-2.6.27.y: nfsd: fix vm overcommit crash fix #2

Erez Zadok ezk at fsl.cs.sunysb.edu
Thu Aug 12 23:15:25 EDT 2010


commit c0ac27236d86f07e1b24126bd7ee0eeb9008eaaf
Author: Junjiro R. Okajima <hooanon05 at yahoo.co.jp>
Date:   Tue Dec 2 10:31:46 2008 -0800

    nfsd: fix vm overcommit crash fix #2
    
    commit 1b79cd04fab80be61dcd2732e2423aafde9a4c1c upstream.
    
    The previous patch from Alan Cox ("nfsd: fix vm overcommit crash",
    commit 731572d39fcd3498702eda4600db4c43d51e0b26) fixed the problem where
    knfsd crashes on exported shmemfs objects and strict overcommit is set.
    
    But the patch forgot supporting the case when CONFIG_SECURITY is
    disabled.
    
    This patch copies a part of his fix which is mainly for detecting a bug
    earlier.
    
    Acked-by: James Morris <jmorris at namei.org>
    Signed-off-by: Alan Cox <alan at redhat.com>
    Signed-off-by: Junjiro R. Okajima <hooanon05 at yahoo.co.jp>
    Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>

diff --git a/include/linux/security.h b/include/linux/security.h
index afb426a..0601e71 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -1823,17 +1823,21 @@ static inline int security_settime(struct timespec *ts, struct timezone *tz)
 
 static inline int security_vm_enough_memory(long pages)
 {
+	WARN_ON(current->mm == NULL);
 	return cap_vm_enough_memory(current->mm, pages);
 }
 
-static inline int security_vm_enough_memory_kern(long pages)
+static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
 {
-	return cap_vm_enough_memory(current->mm, pages);
+	WARN_ON(mm == NULL);
+	return cap_vm_enough_memory(mm, pages);
 }
 
-static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
+static inline int security_vm_enough_memory_kern(long pages)
 {
-	return cap_vm_enough_memory(mm, pages);
+	/* If current->mm is a kernel thread then we will pass NULL,
+	   for this specific case that is fine */
+	return cap_vm_enough_memory(current->mm, pages);
 }
 
 static inline int security_bprm_alloc(struct linux_binprm *bprm)


More information about the unionfs-cvs mailing list