Skip to content

Commit

Permalink
mm: reorder can_do_mlock to fix audit denial
Browse files Browse the repository at this point in the history
A userspace call to mmap(MAP_LOCKED) may result in the successful locking
of memory while also producing a confusing audit log denial.  can_do_mlock
checks capable and rlimit.  If either of these return positive
can_do_mlock returns true.  The capable check leads to an LSM hook used by
apparmour and selinux which produce the audit denial.  Reordering so
rlimit is checked first eliminates the denial on success, only recording a
denial when the lock is unsuccessful as a result of the denial.

Signed-off-by: Jeff Vander Stoep <[email protected]>
Acked-by: Nick Kralevich <[email protected]>
Cc: Jeff Vander Stoep <[email protected]>
Cc: Sasha Levin <[email protected]>
Cc: "Paul E. McKenney" <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Paul Cassella <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jeffvanderstoep authored and torvalds committed Mar 13, 2015
1 parent d3733e5 commit a5a6579
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mm/mlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@

int can_do_mlock(void)
{
if (capable(CAP_IPC_LOCK))
return 1;
if (rlimit(RLIMIT_MEMLOCK) != 0)
return 1;
if (capable(CAP_IPC_LOCK))
return 1;
return 0;
}
EXPORT_SYMBOL(can_do_mlock);
Expand Down

0 comments on commit a5a6579

Please sign in to comment.