Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Mar 2021 15:31:03 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 254661] Debug registers seem to be inherited in forked processes
Message-ID:  <bug-254661-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D254661

            Bug ID: 254661
           Summary: Debug registers seem to be inherited in forked
                    processes
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: mgorny@gentoo.org
                CC: emaste@freebsd.org, kib@FreeBSD.org

Created attachment 223712
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D223712&action=
=3Dedit
fbsd-fork-dbreg.c

It seems that when a process forks, the new child process inherits debug
registers from the parent.  Not sure if this is desirable but it's certainly
different than e.g. Linux and NetBSD do (both clear dbregs in the new proce=
ss).

This currently breaks e.g. GDB that doesn't account for this.  If the proce=
ss
has any watchpoints set before forking, the watchpoints leak to child proce=
ss
when it's being detached, and it crashes with SIGTRAP afterwards.

I'm attaching yet another variant of my cheap reproducer script=E2=84=A2.  =
It sets
dbreg on the parent process before fork, and then reads dbreg from the child
after fork.

The results I get are:

dr0 =3D 0x204690   // set in parent process
dr7 =3D 00000013
dr0 =3D 0x204690   // read in child process
dr7 =3D 00000413

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-254661-227>