On 2018/10/25 21:17, Oleg Nesterov wrote:
>>> 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) {

Reply via email to