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/>

index | next in thread | raw e-mail

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254661

            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=223712&action=edit
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 process).

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

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

The results I get are:

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

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

help

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