Thread (31 messages) 31 messages, 4 authors, 2019-01-16

Re: KASAN: use-after-free Read in task_is_descendant

From: Oleg Nesterov <oleg@redhat.com>
Date: 2018-10-25 12:05:27
Also in: lkml

On 10/25, Kees Cook wrote:
On Thu, Oct 25, 2018 at 12:13 PM, Oleg Nesterov [off-list ref] wrote:
quoted
So again, suppose that "child" is already dead. Its task_struct can't be freed,
but child->real_parent can point to the already freed memory.
I can't find a path for "child" to be released. I see task_lock()
always called on it before it ends up in Yama.
Are you saying that yama_ptrace_access_check() is always called under
task_lock(child) ? Yes, it seems so

So what? Say, ptrace_attach() can hit a dead task. It should notice this
and fail later, but security_ptrace_access_check() is called before that.

quoted
This means that the 1st walker = rcu_dereference(walker->real_parent) is fine,
this simply reads the child->real_parent pointer, but on the second iteration

        walker = rcu_dereference(walker->real_parent);

reads the alredy freed memory.
What does rcu_read_lock() protect actually protect here? I thought
none of the task structs would be freed until after all
rcu_read_unlock() finished.
See another email I sent you a minute ago.

Oleg.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help