[Devel] [PATCH RH7 1/2] Improve vps_dumpable check in __ptrace_may_access()

Vasily Averin vvs at virtuozzo.com
Tue Jan 12 12:47:09 MSK 2021


__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 at virtuozzo.com>
---
 kernel/ptrace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 @@ int __ptrace_may_access(struct task_struct *task, unsigned int mode)
 		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;
 	}
-- 
1.8.3.1



More information about the Devel mailing list