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

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

From: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Date: 2018-10-25 13:15:25
Also in: lkml

On 2018/10/25 21:17, Oleg Nesterov wrote:
quoted
quoted
And yes, task_is_descendant() can hit the dead child, if nothing else it can
be killed. This can explain the kasan report.
The kasan is reporting that child->real_parent (or maybe child->real_parent->real_parent
or child->real_parent->real_parent->real_parent ...) was pointing to already freed memory,
isn't it?
Yes. and you know, I am all confused. I no longer can understand you :/
Why don't we need to check every time like shown below?
Why checking only once is sufficient?
--- a/security/yama/yama_lsm.c
+++ b/security/yama/yama_lsm.c
@@ -285,7 +285,7 @@ static int task_is_descendant(struct task_struct *parent,
 	rcu_read_lock();
 	if (!thread_group_leader(parent))
 		parent = rcu_dereference(parent->group_leader);
-	while (walker->pid > 0) {
+	while (pid_alive(walker) && walker->pid > 0) {
 		if (!thread_group_leader(walker))
 			walker = rcu_dereference(walker->group_leader);
 		if (walker == parent) {
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help