Page MenuHomeFreeBSD

[RFC] Adjust kern.usrstack sysctl by stack gap.
AbandonedPublic

Authored by dgr_semihalf.com on Aug 26 2021, 1:57 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 18, 1:08 AM
Unknown Object (File)
Sat, Mar 15, 1:17 PM
Unknown Object (File)
Mar 6 2025, 2:57 AM
Unknown Object (File)
Feb 28 2025, 2:22 AM
Unknown Object (File)
Feb 23 2025, 5:15 PM
Unknown Object (File)
Feb 22 2025, 3:40 PM
Unknown Object (File)
Feb 22 2025, 12:52 PM
Unknown Object (File)
Feb 20 2025, 2:49 PM

Details

Reviewers
mw
emaste
imp
kib
cy
Summary

kern.usrstack sysctl is used by some programs (e.g. firefox) when
creating threads. This sysctl returns hardcoded value. When stack
gap is enabled, the stack is instead moved by a random amount of
bytes. This can cause those programs to crash.

Adjust kern.usrstack value by the size of stack gap. This fixes the
issue with firefox not starting with stack gap enabled.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dgr_semihalf.com created this revision.

This requires D31516.

Another approach would be to leave this sysctl as is and instead create a new one which could be used to read the actual stack position with stack gap enabled.

This does address the firefox and thunderbird segfaults.

No, this is not going to work. Problem is that the same sysctl is used by programs to get _other_ processes stack address, in particular pstrings location.

Abandoning this, I created D31897 and D31898, which add a different sysctl and modify libthr to use it.