Bug 252109 - With ASLR enabled ulimit -s is crashing
Summary: With ASLR enabled ulimit -s is crashing
Status: Closed Works As Intended
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 12.2-RELEASE
Hardware: amd64 Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-24 15:24 UTC by Daniel
Modified: 2020-12-24 15:52 UTC (History)
2 users (show)

See Also:


Attachments
coredump from ulimit (83.00 KB, application/x-gzip)
2020-12-24 15:24 UTC, Daniel
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel 2020-12-24 15:24:48 UTC
Created attachment 220893 [details]
coredump from ulimit

Summary
When trying to set a stack size using ulimit -s while kern.elf*.aslr.enable=1 causes segmentation fault:

System:
OS: 12.2-RELEASE-p1 
ARCH: AMD64
Notes: Running on Proxmox VM


Steps to reproduce:
root@abyss:~ # sysctl kern.elf64.aslr.enable=1
kern.elf64.aslr.enable: 1 -> 1
root@abyss:~ # sysctl kern.elf64.aslr.enable=0
kern.elf64.aslr.enable: 1 -> 0
root@abyss:~ # ulimit -s 3000
root@abyss:~ # ulimit -s 3000
root@abyss:~ # ulimit -s 3000
root@abyss:~ # ulimit -s 3000
root@abyss:~ # ulimit -s 3000
root@abyss:~ # sysctl kern.elf64.aslr.enable=1
kern.elf64.aslr.enable: 0 -> 1
root@abyss:~ # ulimit -s 3000
Segmentation fault (core dumped)
root@abyss:~ #

Workaround:
Disable ASLR sysctl kern.elf64.aslr.enable=0

Attached coredump from ulimit.
Comment 1 Konstantin Belousov freebsd_committer freebsd_triage 2020-12-24 15:51:52 UTC
There is ASLR stack gap that randomizes stack location under the limit of
the main thread stack.  You cannot reduce stack size past the gap.

If you so inclined, disable gap with either kern.elf64.aslr.stack_gap set to zero,
or wait until stable/12 gets the ELF flag to disable stack gap merged.