Skip to content

Commit

Permalink
nfsd: fix vm overcommit crash fix #2
Browse files Browse the repository at this point in the history
The previous patch from Alan Cox ("nfsd: fix vm overcommit crash",
commit 731572d) 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 <[email protected]>
Signed-off-by: Alan Cox <[email protected]>
Signed-off-by: Junjiro R. Okajima <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Junjiro R. Okajima authored and torvalds committed Dec 2, 2008
1 parent 061e41f commit 1b79cd0
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -1818,17 +1818,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)
Expand Down

0 comments on commit 1b79cd0

Please sign in to comment.