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

(cherry picked from commit 889b56c8cd84c9a9f2d9e3b019c154d6f14d9021)

Details

Provenance
dgr_semihalf.comAuthored on Oct 13 2021, 7:01 PM
mwCommitted on Dec 30 2021, 3:24 PM
Reviewer
kib
Differential Revision
D31516: setrlimit: Take stack gap into account.
Parents
rG52ce808aba3f: bsdinstall: zfsboot: Prompt user for zpool name if the pool already exists
Branches
Unknown
Tags
Unknown