[RHEL7,COMMIT] Improve vps_dumpable check in __ptrace_may_access()

Submitted by Vasily Averin on Jan. 13, 2021, 10:25 a.m.

Details

Message ID 202101131025.10DAPKld009633@vz7build.vvs.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Vasily Averin Jan. 13, 2021, 10:25 a.m.
The commit is pushed to "branch-rh7-3.10.0-1160.11.1.vz7.172.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.11.1.vz7.172.9
------>
commit 9c9eb0f3b907a14875ab307466721a81b68bf3ee
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Wed Jan 13 13:25:20 2021 +0300

    Improve vps_dumpable check in __ptrace_may_access()
    
    __ptrace_may_access() is used when someone tries to
    readlink /proc/$PID/ns/$SOMENS and gets -EPERM for kthreads
    because they lack task->mm and thus "vps_dumpable" field.
    
    Let's return error only for non-kernel threads and follow usual
    restrictions for kernel threads.
    
    https://jira.sw.ru/browse/PSBM-92107
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 kernel/ptrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 4b7dd80..a3622fe 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -294,7 +294,7 @@  ok:
 		rcu_read_unlock();
 		return -EPERM;
 	}
-	if (!vps_dumpable && !ve_is_super(get_exec_env())) {
+	if (task->mm && !vps_dumpable && !ve_is_super(get_exec_env())) {
 		rcu_read_unlock();
 		return -EPERM;
 	}