cross memory attach && security check

From: Oleg Nesterov
Date: Thu Jan 05 2012 - 10:15:58 EST


Hello,

Just noticed the new file in mm/ ;) A couple of questions.

process_vm_rw_core() does

task_lock(task);
if (__ptrace_may_access(task, PTRACE_MODE_ATTACH)) {
task_unlock(task);
rc = -EPERM;
goto put_task_struct;
}
mm = task->mm;

this is racy, task_lock() can't help. And I don't think you should
use it directly.

execve() does exec_mmap() first, this switches to the new ->mm.
After that install_exec_creds() changes task->cred. The window
is not that small.

I guess you need ->cred_guard_mutex, please look at mm_for_maps().




Another question, process_vm_rw_pages() does get_user_pages() without
FOLL_FORCE. Is this on purpose? This limits the usage of the new
syscalls.




Hmm. And could you please explain the change in rw_copy_check_uvector()?
Why process_vm_rw() does
rw_copy_check_uvector(READ, rvec, check_access => 0) ?

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/