Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Oct 2019 20:31:47 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Cy Schubert <Cy.Schubert@cschubert.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: ASLR and Stack Gap != 0
Message-ID:  <20191026173147.GN73312@kib.kiev.ua>
In-Reply-To: <201910261728.x9QHS7av001087@slippy.cwsent.com>
References:  <201910261728.x9QHS7av001087@slippy.cwsent.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Oct 26, 2019 at 10:28:07AM -0700, Cy Schubert wrote:
> Let's try this again. This time with a subject line.
> 
> 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.
> 
I already explained this, also you might find this written down one
more time at
https://github.com/freebsd/freebsd-quarterly/blob/master/2019q3/stack_gap.md



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20191026173147.GN73312>