tests/sys/kern/procdesc: test the debugger's wait after the last close
Attach a debugger to a PD_NOWAITPID child, let the child exit, and let
the parent close the last process descriptor before the debugger waits.
Check that a debugger which is neither the parent nor the reaper can
still wait for the child, which then goes to the reaper, and that a
reaper which is the debugger can collect the child.
The child exits on its own: kill(2) does not kill a traced process, it
only stops it for the debugger.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
amd64, powerpc64: treat procctl(P_PID, 0) as request for current process
Discussed with: markj
Fixes: f833ab9dd187 ("procctl(2): add consistent shortcut P_ID:0 as curproc")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D61919
tests/sys/kern/procdesc: test the reap by a close from a non-parent
The parent waits for its pdfork(2) child, and then another process,
which inherited the descriptor over fork(2), closes the last one and so
reaps the zombie. Check that the child's resource usage is accounted
to the parent and not to the closing process, and that the child's
SIGCHLD is no longer pending for the parent.
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
proc_reap(): account the reaped child to its parent
When the last process descriptor of a zombie is closed by a process
other than its parent, proc_reap() added the child's resource usage to
the closing process instead of the parent. Add it to the parent, and do
it before dropping proctree_lock, which keeps the parent from being
reaped meanwhile.
Reported by: llm-postcr
Fixes: cfb5f7686588 ("Add experimental support for process descriptors")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
proc_reap(): dequeue the child's SIGCHLD under the parent's lock
p_ksi is only queued to the parent, but proc_reap() took it off the
queue with the caller locked. When the last process descriptor of a
zombie is closed by a process other than its parent, e.g. one which
inherited the descriptor over fork(2) or opened it with pdopenpid(2),
the parent's signal queue and p_pendingcnt were modified without the
parent's lock.
Since bcdb6ba94d08 this is easy to hit: a pdfork(2) child without
PD_NOWAITPID signals its parent with p_ksi on exit, and while the
descriptor is open, the parent's wait only drops PZOMBIEREF_PARENT and
leaves p_ksi queued if the parent blocks or catches SIGCHLD.
Lock the parent, as proc_reparent() does.
Reported by: llm-postcr
Fixes: cfb5f7686588 ("Add experimental support for process descriptors")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
procdesc_close(): leave a zombie parked at its debugger with it
A debugger which is not the parent of a PD_NOWAITPID child, and got the
child via PT_ATTACH, can wait for the child after it exited. If the
parent closed the last process descriptor before the debugger waited,
the close dropped the last zombie reference, and proc_reap() gave the
zombie back to the real parent. The real parent cannot wait for a
PD_NOWAITPID child, and the debugger got ECHILD, so the zombie stayed
until the real parent exited.
Handle a zombie parked at its debugger as procdesc_close() handles a
traced live process: keep it with the debugger, and make the reaper the
real parent. The debugger's wait then gives the zombie to the reaper,
which proc_reparent() lets wait for it. A debugger which is the reaper
gets PZOMBIEREF_PARENT right away.
Reported by: llm-postcr
Fixes: bcdb6ba94d08 ("processes: add zombie references, each of them prevents reap")
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
kern.post.mk: Further refine ports module build
A handful of kmod ports have NO_PACKAGE set, which disables the package
target, which means the previous commit made things worse for those
ports rather than better. Work around this by explicitly building the
stage target first.
Fixes: b393df657811 ("kern.post.mk: Fix unprivileged ports module build")
rtwn: (RTL8192FU) fix init, with_ucode build and tx power handling
- added noop for RTWN_WITHOUT_UCODE builds on sc_set_media_status
- fixed upper bound of power delta for MCS for HT20/HT40 in tx power
- moved reading per channel bb trim values after efuse and bb initialization
- use 256 bytes per TX pages as per vendor and linux rtl8xxxu
- added tab character instead of spaces in share/misc/usb_vendors after the device name
Tested on RTL8192FU
Sponsored by: Alchemilla Ventures Private Limited
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D62241
Reported by: llm-postcr
Fixes: 1f0e186e1832 ("rtwn: added support for Realtek RTL8192FU...")
rge(4): Fix build without INET
rge_tx_pad() calls in_delayed_cksum_o() and in_cksum_skip()
unconditionally. in_delayed_cksum_o() lives in netinet/ip_output.c
(optional inet) and in_cksum_skip() lives in netinet/in_cksum.c
(optional inet | inet6). So kernels with "device rge" and no
INET fail to link. This breaks LINT-NOINET and LINT-NOIP.
Include opt_inet.h, add it to the module's SRCS, and wrap the IPv4
software checksum block in #ifdef INET.
Fixes: e3ded948ad41 ("rge(4): Implement RTL8125 UDP hardware workaround")
Reported by: llm-postcr
Differential Revision: https://reviews.freebsd.org/D62240