HomeFreeBSD

ktrace: Fix a race with fork()

Description

ktrace: Fix a race with fork()

ktrace(2) may toggle trace points in any of

  1. a single process
  2. all members of a process group
  3. all descendents of the processes in 1 or 2

In the first two cases, we do not permit the operation if the process is
being forked or not visible. However, in case 3 we did not enforce this
restriction for descendents. As a result, the assertions about the child
in ktrprocfork() may be violated.

Move these checks into ktrops() so that they are applied consistently.

Allow KTROP_CLEAR for nascent processes. Otherwise, there is a window
where we cannot clear trace points for a nascent child if they are
inherited from the parent.

Reported by: syzbot+d96676592978f137e05c@syzkaller.appspotmail.com
Reported by: syzbot+7c98fcf84a4439f2817f@syzkaller.appspotmail.com
Reviewed by: kib
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D30481

Details

Provenance
markjAuthored on May 27 2021, 7:49 PM
Reviewer
kib
Differential Revision
D30481: ktrace: Fix a race with fork()
Parents
rGe00bae5c181a: kevent: Prohibit negative change and event list lengths
Branches
Unknown
Tags
Unknown