Page MenuHomeFreeBSD

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

Authored by dgr_semihalf.com on Aug 26 2021, 1:57 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
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.