Page MenuHomeFreeBSD

kern_exec: Add kern.stacktop sysctl.
ClosedPublic

Authored by dgr_semihalf.com on Sep 10 2021, 6:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Nov 7, 4:51 AM
Unknown Object (File)
Thu, Nov 7, 1:19 AM
Unknown Object (File)
Thu, Nov 7, 12:16 AM
Unknown Object (File)
Tue, Nov 5, 1:46 PM
Unknown Object (File)
Tue, Nov 5, 11:48 AM
Unknown Object (File)
Mon, Oct 28, 7:39 PM
Unknown Object (File)
Sun, Oct 27, 12:43 AM
Unknown Object (File)
Sat, Oct 26, 10:28 AM

Details

Summary

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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dgr_semihalf.com created this revision.

Hi, do you have any further comments or remarks? If there are no objections, I'm going to merge this patch by EOW.

sys/kern/kern_exec.c
137

Style: need spaces around binary op '|'. Ignore other examples in this file, do it right for added code.

199–223

Fix style while there: return (error);

237

The op ('-') should be on the previous line, before line split. Also, why not to do single cast, instead of two:

val = (unsigned)(p->p_sysent->sv_usrstack - p->p_vmspace->vm_stkgap);
246

return (error);

kib added inline comments.
sys/kern/kern_exec.c
213

There should be a blank line after local variable declaration.

This revision is now accepted and ready to land.Oct 13 2021, 11:13 PM

Added newline after variable declaration.

This revision now requires review to proceed.Oct 14 2021, 9:16 AM
This revision is now accepted and ready to land.Oct 14 2021, 2:25 PM
This revision was automatically updated to reflect the committed changes.