diff mbox series

mm/madvise: remove racy mm ownership check

Message ID 20201209032155.564991-1-minchan@kernel.org (mailing list archive)
State New, archived
Headers show
Series mm/madvise: remove racy mm ownership check | expand

Commit Message

Minchan Kim Dec. 9, 2020, 3:21 a.m. UTC
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.

Cc: security@kernel.org
Fixes: ecb8ac8b1f14 ("mm/madvise: introduce process_madvise() syscall: an external memory hinting API")
Reported-by: Jann Horn <jannh@google.com>
Suggested-by: Jann Horn <jannh@google.com>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
 mm/madvise.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Linus Torvalds Dec. 9, 2020, 4:58 a.m. UTC | #1
On Tue, Dec 8, 2020 at 7:22 PM Minchan Kim <minchan@kernel.org> wrote:
>
> 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.

Applied directly - I'm not sure Andrew has anything else pending, so
might as well short-circuit it.

              Linus
diff mbox series

Patch

diff --git a/mm/madvise.c b/mm/madvise.c
index a8d8d48a57fe..13f5677b9322 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;
 	}