ptrace_may_access() vs euid checks in futex.c
Posted: Wed Dec 21, 2011 11:36 am
We noticed that, when PROC_MEMMAP is turned on, the futex code (get_robust_list()) uses ptrace_may_access() instead of doing euid checks, ie.:
instead of:
Now, ptrace_may_access(), does check the current process' uid against the target process' euid:
but not the opposite. This causes this code, run as 'root':
to succeed, while it fails on a non PROC_MEMMAP-enabled kernel.
What is the rationale behind this difference ?
- Code: Select all
if (!ptrace_may_access(p, PTRACE_MODE_READ))
goto err_unlock;
instead of:
- Code: Select all
pcred = __task_cred(p);
if (cred->euid != pcred->euid &&
cred->euid != pcred->uid &&
!capable(CAP_SYS_PTRACE))
goto err_unlock;
Now, ptrace_may_access(), does check the current process' uid against the target process' euid:
- Code: Select all
tcred = __task_cred(task);
if ((cred->uid != tcred->euid ||
but not the opposite. This causes this code, run as 'root':
- Code: Select all
seteuid(1);
get_robust_list(1, &head, &len);
to succeed, while it fails on a non PROC_MEMMAP-enabled kernel.
What is the rationale behind this difference ?