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

Submitted by Vasily Averin on Jan. 12, 2021, 9:47 a.m.

Details

Message ID c73d6948-324b-b02c-e3cc-dffd1f3cd344@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Vasily Averin Jan. 12, 2021, 9:47 a.m.
__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 @@  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;
 	}