Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
[linux-2.6-block.git] / include / linux / security.h
index f5c4a51eb42ea9ec97f460e14a11c24850de82be..e3d4ecda267381d85da5697b2ad681c1da749fe3 100644 (file)
@@ -1585,6 +1585,7 @@ int security_syslog(int type);
 int security_settime(struct timespec *ts, struct timezone *tz);
 int security_vm_enough_memory(long pages);
 int security_vm_enough_memory_mm(struct mm_struct *mm, long pages);
+int security_vm_enough_memory_kern(long pages);
 int security_bprm_alloc(struct linux_binprm *bprm);
 void security_bprm_free(struct linux_binprm *bprm);
 void security_bprm_apply_creds(struct linux_binprm *bprm, int unsafe);
@@ -1817,14 +1818,23 @@ 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_mm(struct mm_struct *mm, long pages)
 {
+       WARN_ON(mm == NULL);
        return cap_vm_enough_memory(mm, pages);
 }
 
+static inline int security_vm_enough_memory_kern(long 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)
 {
        return 0;