From: Oleg Nesterov <oleg@redhat.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: serge@hallyn.com,
syzbot <syzbot+a9ac39bf55329e206219@syzkaller.appspotmail.com>,
jmorris@namei.org, keescook@chromium.org,
linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
syzkaller-bugs@googlegroups.com
Subject: Re: KASAN: use-after-free Read in task_is_descendant
Date: Fri, 26 Oct 2018 15:04:42 +0200 [thread overview]
Message-ID: <20181026130442.GB10581@redhat.com> (raw)
In-Reply-To: <3423a470-c152-0dbf-c7a7-2775a9679194@i-love.sakura.ne.jp>
On 10/26, Tetsuo Handa wrote:
>
> Since the "child" passed to task_is_descendant() has at least one reference
> count taken by find_get_task_by_vpid(), rcu_dereference(walker->real_parent)
> in the first iteration
>
> while (child->pid > 0) {
> if (!thread_group_leader(child))
> walker = rcu_dereference(child->group_leader);
> if (walker == parent) {
> rc = 1;
> break;
> }
> walker = rcu_dereference(walker->real_parent);
> }
>
> must not trigger use-after-free bug.
Yes,
> Thus, when this use-after-free was
> detected at rcu_dereference(walker->real_parent), the memory pointed by
> "walker" must have been released between
>
> while (walker->pid > 0) {
> if (!thread_group_leader(walker))
> walker = rcu_dereference(walker->group_leader);
>
> and
>
> walker = rcu_dereference(walker->real_parent);
> }
this is possible too, rcu callback which frees the task_struct can run
int between
> because otherwise use-after-free would have been reported at walker->pid
> or thread_group_leader(walker) or rcu_dereference(walker->group_leader).
Well, I do not know how much kasan is "percise", but if it is "perfect"
then you are right,
> Then, what pid_alive(child) is testing?
I tried to explain this in my previous email. I even mentioned that we could
do another check, say, ->sighand != NULL, or list_empty(child->sibling) with
the same effect.
> Suppose p1 == p2->real_parent and p2 == p3->real_parent, and p1 exited
> when p2 tried to attach on p1, p2->real_parent was pointing to already
> (or about to be) freed p1.
No, p2->real_parent will be updated. If p1 exits it will re-parent its
children including p2.
Again, did you read my previous email?
Let me repeat, of course I can be wrong. But so far I am answering the
same questions again and again...
Oleg.
next prev parent reply other threads:[~2018-10-26 13:04 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-21 7:10 KASAN: use-after-free Read in task_is_descendant syzbot
2018-10-21 7:12 ` Tetsuo Handa
2018-10-22 9:54 ` Oleg Nesterov
2018-10-22 10:06 ` Tetsuo Handa
2018-10-22 13:46 ` Oleg Nesterov
2018-10-25 2:15 ` Tetsuo Handa
2018-10-25 11:13 ` Oleg Nesterov
2018-10-25 11:36 ` Kees Cook
2018-10-25 12:05 ` Oleg Nesterov
2018-10-25 11:47 ` Tetsuo Handa
2018-10-25 12:17 ` Oleg Nesterov
2018-10-25 13:01 ` Oleg Nesterov
2018-10-26 16:09 ` Kees Cook
2018-10-29 12:23 ` Oleg Nesterov
2018-10-29 15:05 ` yama: unsafe usage of ptrace_relation->tracer Oleg Nesterov
2019-01-10 11:05 ` Tetsuo Handa
2019-01-10 18:47 ` Kees Cook
2019-01-16 17:40 ` Oleg Nesterov
2018-10-25 13:14 ` KASAN: use-after-free Read in task_is_descendant Tetsuo Handa
2018-10-25 15:55 ` Oleg Nesterov
2018-10-25 16:25 ` Oleg Nesterov
2018-10-26 12:23 ` Tetsuo Handa
2018-10-26 13:04 ` Oleg Nesterov [this message]
2018-10-26 13:51 ` Tetsuo Handa
2018-10-26 14:39 ` Oleg Nesterov
2018-10-26 15:04 ` Tetsuo Handa
2018-10-26 15:22 ` Oleg Nesterov
2018-10-25 8:19 ` Kees Cook
2018-10-25 11:52 ` Oleg Nesterov
2018-11-10 3:25 ` syzbot
2018-11-10 11:46 ` syzbot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181026130442.GB10581@redhat.com \
--to=oleg@redhat.com \
--cc=jmorris@namei.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=serge@hallyn.com \
--cc=syzbot+a9ac39bf55329e206219@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).