[Bug 254661] Debug registers seem to be inherited in forked processes
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Tue Mar 30 15:31:03 UTC 2021
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 at FreeBSD.org
Reporter: mgorny at gentoo.org
CC: emaste at freebsd.org, kib at 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.
More information about the freebsd-bugs
mailing list