No subject
Cy Schubert
Cy.Schubert at cschubert.com
Sat Oct 26 17:23:05 UTC 2019
Hi,
The following little test case segfaults when aslr is enabled:
#include <stdio.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
int
main(int argc, char *argv[])
{
struct rlimit rl;
int rc;
rl.rlim_cur = 50 * 4096;
rl.rlim_max = 50 * 4096;
rc = setrlimit(RLIMIT_STACK, &rl);
return(rc);
}
slippy# sysctl kern.elf64.aslr.enable=1
kern.elf64.aslr.enable: 0 -> 1
slippy# ./test
Segmentation fault (core dumped)
slippy# gdb test
GNU gdb (GDB) 8.3.1 [GDB v8.3.1 for FreeBSD]
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-portbld-freebsd13.0".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from test...
(gdb) run
Starting program: /export/home/cy/freebsd/tests/setrlimit/test
Program received signal SIGSEGV, Segmentation fault.
setrlimit () at setrlimit.S:4
4 setrlimit.S: No such file or directory.
(gdb) bt
#0 setrlimit () at setrlimit.S:4
Backtrace stopped: Cannot access memory at address 0x7fffffe372e8
(gdb)
It only occurs with aslr enabled and stack gap != 0. This isn't right.
--
Cheers,
Cy Schubert <Cy.Schubert at cschubert.com>
FreeBSD UNIX: <cy at FreeBSD.org> Web: http://www.FreeBSD.org
The need of the many outweighs the greed of the few.
More information about the freebsd-hackers
mailing list