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

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20191026173147.GN73312@kib.kiev.ua>, Konstantin Belousov writes:
> 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.htm
> l
> > >
> > 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

Perfect. Thanks.


-- 
Cheers,
Cy Schubert <Cy.Schubert@cschubert.com>
FreeBSD UNIX:  <cy@FreeBSD.org>   Web:  http://www.FreeBSD.org

	The need of the many outweighs the greed of the few.





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