Summary: | lib.libc.sys.setrlimit_test.setrlimit_stack fails with ASLR on by default | ||
---|---|---|---|
Product: | Base System | Reporter: | Ed Maste <emaste> |
Component: | tests | Assignee: | Mark Johnston <markj> |
Status: | Closed FIXED | ||
Severity: | Affects Only Me | CC: | dgr, lwhsu, markj, vangyzen |
Priority: | --- | ||
Version: | CURRENT | ||
Hardware: | Any | ||
OS: | Any | ||
See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260303 | ||
Bug Depends on: | |||
Bug Blocks: | 259968 |
Description
Ed Maste
2021-11-21 16:05:48 UTC
Source reference: contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c This issue is caused by the way setrlimit handles stack gap. Currently setrlimit does know about stack gap, however only the rlim_cur value is adjusted taking into consideration the size of the stack gap. rlim_max is a hard limit, so we don't adjust it. This test sets stack both rlim_cur and rlim_max to around 4MiB. By default stack gap that FreeBSD has can be as big as 3% of maximum stack size, so for amd64 this is around 15M. Because of that, when trying to set stack limit to 4M, in most cases the test will receive SIGSEGV immediately when exiting the syscall. Adjusting the resource limit from 4M to a value higher than maximum stack gap size should resolve this problem. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=dad71022bd7a8f95ab2ba656bec61e2424a1c3c5 commit dad71022bd7a8f95ab2ba656bec61e2424a1c3c5 Author: Li-Wen Hsu <lwhsu@FreeBSD.org> AuthorDate: 2021-11-28 06:58:21 +0000 Commit: Li-Wen Hsu <lwhsu@FreeBSD.org> CommitDate: 2021-11-28 06:58:21 +0000 Disable flaky test lib.libc.sys.setrlimit_test.setrlimit_stack PR: 259969 Sponsored by: The FreeBSD Foundation contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c | 3 +++ 1 file changed, 3 insertions(+) By the way, lib/libc/regex/exhaust_test:regcomp_too_big also fails often when ASLR stack_gap is enabled, apparently due to stack overflow. (This test also runs under lib/libregex.) (In reply to Eric van Gyzen from comment #5) Yep, that's PR 259971. A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=7bd2df8c82e863396ae96ad4c43418c762e9f702 commit 7bd2df8c82e863396ae96ad4c43418c762e9f702 Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2022-01-14 19:58:56 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2022-01-14 19:58:56 +0000 Revert "Disable flaky test lib.libc.sys.setrlimit_test.setrlimit_stack" The stack gap implementation is disabled by default now, so the test passes. This reverts commit dad71022bd7a8f95ab2ba656bec61e2424a1c3c5. PR: 259969 MFC after: 1 week Sponsored by: The FreeBSD Foundation contrib/netbsd-tests/lib/libc/sys/t_setrlimit.c | 3 --- 1 file changed, 3 deletions(-) Closing for now, the stack gap rework will avoid regressing this test again. |