linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/madvise: remove racy mm ownership check
@ 2020-12-09  3:21 Minchan Kim
  2020-12-09  4:58 ` Linus Torvalds
  0 siblings, 1 reply; 2+ messages in thread
From: Minchan Kim @ 2020-12-09  3:21 UTC (permalink / raw)
  To: akpm, torvalds
  Cc: LKML, linux-mm, jannh, mhocko, shakeelb, surenb, christian,
	rientjes, bgeffon, vbabka, Minchan Kim, security

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(-)

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;
 	}
-- 
2.29.2.576.ga3fc446d84-goog



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm/madvise: remove racy mm ownership check
  2020-12-09  3:21 [PATCH] mm/madvise: remove racy mm ownership check Minchan Kim
@ 2020-12-09  4:58 ` Linus Torvalds
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2020-12-09  4:58 UTC (permalink / raw)
  To: Minchan Kim
  Cc: Andrew Morton, LKML, linux-mm, Jann Horn, Michal Hocko,
	Shakeel Butt, Suren Baghdasaryan, Christian Brauner,
	David Rientjes, Brian Geffon, Vlastimil Babka, Security Officers

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-09  4:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09  3:21 [PATCH] mm/madvise: remove racy mm ownership check Minchan Kim
2020-12-09  4:58 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).