HomeFreeBSD

setrlimit: Take stack gap into account.

Description

setrlimit: Take stack gap into account.

Calling setrlimit with stack gap enabled and with low values of stack
resource limit often caused the program to abort immediately after
exiting the syscall. This happened due to the fact that the resource
limit was calculated assuming that the stack started at sv_usrstack,
while with stack gap enabled the stack is moved by a random number
of bytes.

Save information about stack size in struct vmspace and adjust the
rlim_cur value. If the rlim_cur and stack gap is bigger than rlim_max,
then the value is truncated to rlim_max.

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

Details

Provenance
dgr_semihalf.comAuthored on Oct 13 2021, 7:01 PM
mwCommitted on Oct 15 2021, 8:21 AM
Reviewer
kib
Differential Revision
D31516: setrlimit: Take stack gap into account.
Parents
rG1b0e2f0b607e: bhyve: ignore low bits of CFGADR
Branches
Unknown
Tags
Unknown