From: Minchan Kim Date: Wed, 9 Dec 2020 04:57:18 +0000 (-0800) Subject: mm/madvise: remove racy mm ownership check X-Git-Tag: v5.10.7~1034 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a68a0262abdaa251e12c53715f48e698a18ef402;p=platform%2Fkernel%2Flinux-rpi.git mm/madvise: remove racy mm ownership check 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: ecb8ac8b1f14 ("mm/madvise: introduce process_madvise() syscall: an external memory hinting API") Reported-by: Jann Horn Suggested-by: Jann Horn Signed-off-by: Minchan Kim Signed-off-by: Linus Torvalds --- diff --git a/mm/madvise.c b/mm/madvise.c index a8d8d48..13f5677 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -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; }