HomeFreeBSD

kern_exec: Add kern.stacktop sysctl.

Description

kern_exec: Add kern.stacktop sysctl.

With stack gap enabled top of the stack is moved down by a random
amount of bytes. Because of that some multithreaded applications
which use kern.usrstack sysctl to calculate address of stacks for
their threads can fail. Add kern.stacktop sysctl, which can be used
to retrieve address of the stack after stack gap is applied to it.
Returns value identical to kern.usrstack for processes which have
no stack gap.

Reviewed by: kib
Obtained from: Semihalf
Sponsored by: Stormshield
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D31897

(cherry picked from commit a97d697122da2bfb0baae5f0939d118d119dae33)

Details

Provenance
dgr_semihalf.comAuthored on Oct 13 2021, 7:03 PM
mwCommitted on Dec 30 2021, 3:25 PM
Reviewer
kib
Differential Revision
D31897: kern_exec: Add kern.stacktop sysctl.
Parents
rG16a900ae0242: setrlimit: Take stack gap into account.
Branches
Unknown
Tags
Unknown