mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 113/131] Unify migrate_pages and move_pages access checks
@ 2017-11-16  1:38 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2017-11-16  1:38 UTC (permalink / raw)
  To: akpm, ebiederm, keescook, mhocko, mm-commits, otto.ebeling, torvalds, w

From: Otto Ebeling <otto.ebeling@iki.fi>
Subject: Unify migrate_pages and move_pages access checks

197e7e521384a23b ("Sanitize 'move_pages()' permission checks") fixed a
security issue I reported in the move_pages syscall, and made it so that
you can't act on set-uid processes unless you have the CAP_SYS_PTRACE
capability.

Unify the access check logic of migrate_pages to match the new behavior of
move_pages.  We discussed this a bit in the security@ list and thought
it'd be good for consistency even though there's no evident security
impact.  The NUMA node access checks are left intact and require
CAP_SYS_NICE as before.

Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1710011830320.6333@lakka.kapsi.fi
Signed-off-by: Otto Ebeling <otto.ebeling@iki.fi>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Willy Tarreau <w@1wt.eu>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 mm/mempolicy.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff -puN mm/mempolicy.c~unify-migrate_pages-and-move_pages-access-checks mm/mempolicy.c
--- a/mm/mempolicy.c~unify-migrate_pages-and-move_pages-access-checks
+++ a/mm/mempolicy.c
@@ -85,6 +85,7 @@
 #include <linux/interrupt.h>
 #include <linux/init.h>
 #include <linux/compat.h>
+#include <linux/ptrace.h>
 #include <linux/swap.h>
 #include <linux/seq_file.h>
 #include <linux/proc_fs.h>
@@ -1365,7 +1366,6 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pi
 		const unsigned long __user *, old_nodes,
 		const unsigned long __user *, new_nodes)
 {
-	const struct cred *cred = current_cred(), *tcred;
 	struct mm_struct *mm = NULL;
 	struct task_struct *task;
 	nodemask_t task_nodes;
@@ -1401,15 +1401,10 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pi
 	err = -EINVAL;
 
 	/*
-	 * Check if this process has the right to modify the specified
-	 * process. The right exists if the process has administrative
-	 * capabilities, superuser privileges or the same
-	 * userid as the target process.
+	 * Check if this process has the right to modify the specified process.
+	 * Use the regular "ptrace_may_access()" checks.
 	 */
-	tcred = __task_cred(task);
-	if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
-	    !uid_eq(cred->uid,  tcred->suid) && !uid_eq(cred->uid,  tcred->uid) &&
-	    !capable(CAP_SYS_NICE)) {
+	if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS)) {
 		rcu_read_unlock();
 		err = -EPERM;
 		goto out_put;
_

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-11-16  1:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16  1:38 [patch 113/131] Unify migrate_pages and move_pages access checks akpm

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