Skip to content

Commit

Permalink
mm/madvise: remove racy mm ownership check
Browse files Browse the repository at this point in the history
Jann spotted the security hole due to race of mm ownership check.

If the task is sharing the mm_struct but goes through execve() before
mm_access(), it could skip process_madvise_behavior_valid check.  That
makes *any advice hint* to reach into the remote process.

This patch removes the mm ownership check.  With it, it will lose the
ability that local process could give *any* advice hint with vector
interface for some reason (e.g., performance).  Since there is no
concrete example in upstream yet, it would be better to remove the
abiliity at this moment and need to review when such new advice comes
up.

Fixes: ecb8ac8 ("mm/madvise: introduce process_madvise() syscall: an external memory hinting API")
Reported-by: Jann Horn <[email protected]>
Suggested-by: Jann Horn <[email protected]>
Signed-off-by: Minchan Kim <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
minchank authored and torvalds committed Dec 9, 2020
1 parent 4cb6829 commit a68a026
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,7 @@ SYSCALL_DEFINE5(process_madvise, int, pidfd, const struct iovec __user *, vec,
goto put_pid;
}

if (task->mm != current->mm &&
!process_madvise_behavior_valid(behavior)) {
if (!process_madvise_behavior_valid(behavior)) {
ret = -EINVAL;
goto release_task;
}
Expand Down

0 comments on commit a68a026

Please sign in to comment.