Avoid reusing p_ksi while it is on queue.
authorkib <kib@FreeBSD.org>
Sun, 12 Mar 2017 13:58:51 +0000 (13:58 +0000)
committerkib <kib@FreeBSD.org>
Sun, 12 Mar 2017 13:58:51 +0000 (13:58 +0000)
commit34f9433195a05904855d2ce1e52bcc3888964bd8
treee3c13804a845c072f3b8fb15198c0e1a569bddd5
parentdada1184e876b5b38e8411fbb1605af91e993654
Avoid reusing p_ksi while it is on queue.

When sending SIGCHLD informing reaper that a zombie was reparented to
it, we might race with the situation where the previous parent still
not finished delivering SIGCHLD and having its p_ksi structure on the
signal queue.  While on queue, the ksi should not be used for another
send.

Fix this by copying p_ksi into newly allocated ksi, which is directly
put onto reaper sigqueue.  The later ensures that siginfo for reaper
SIGCHLD is always present, similar to guarantees for siginfo of child.

Reported by: bdrewery
Discussed with: jilles
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
sys/kern/kern_exit.c