Skip to content

Commit

Permalink
mm: use dedicated helper to access rlimit value
Browse files Browse the repository at this point in the history
Use rlimit() helper instead of manually writing whole chain from current
task to rlim_cur.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Krzysztof Opasiak <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
kopasiak authored and torvalds committed Jul 10, 2017
1 parent b17c070 commit 24c79d8
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions mm/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -2177,23 +2177,22 @@ static int acct_stack_growth(struct vm_area_struct *vma,
unsigned long size, unsigned long grow)
{
struct mm_struct *mm = vma->vm_mm;
struct rlimit *rlim = current->signal->rlim;
unsigned long new_start;

/* address space limit tests */
if (!may_expand_vm(mm, vma->vm_flags, grow))
return -ENOMEM;

/* Stack limit test */
if (size > READ_ONCE(rlim[RLIMIT_STACK].rlim_cur))
if (size > rlimit(RLIMIT_STACK))
return -ENOMEM;

/* mlock limit tests */
if (vma->vm_flags & VM_LOCKED) {
unsigned long locked;
unsigned long limit;
locked = mm->locked_vm + grow;
limit = READ_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
limit = rlimit(RLIMIT_MEMLOCK);
limit >>= PAGE_SHIFT;
if (locked > limit && !capable(CAP_IPC_LOCK))
return -ENOMEM;
Expand Down

0 comments on commit 24c79d8

Please sign in to comment.