From dd94473c5724f8215790a9195df96cfa7bd6a04b Mon Sep 17 00:00:00 2001 From: edef Date: Sat, 30 Jul 2022 17:55:04 +0000 Subject: ripple/minitrace: configure stack rlimits Removing the RLIMIT_STACK soft limit changes address space layout markedly. Change-Id: I64d1a1fc1b397200245d5f790ce126c99d4b4797 --- ripple/minitrace/src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 847fb24..c7fb369 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -10,6 +10,7 @@ use { sys::{ personality::{self, Persona}, ptrace, + resource::{self, Resource as HostResource}, signal::Signal as HostSignal, wait::{waitpid, WaitPidFlag, WaitStatus}, }, @@ -64,6 +65,21 @@ impl Process { persona.insert(Persona::ADDR_NO_RANDOMIZE); personality::set(persona)?; + // set stack limit (to guarantee top-down address space layout) + resource::setrlimit( + HostResource::RLIMIT_STACK, + Some( + // not a particularly meaningful number, + // just plucked from the author's system + 8 * 1024 * 1024, + ), + Some( + 128 * 1024 * 1024 + // guard page + - 4096, + ), + )?; + ptrace::traceme()?; Ok(()) }); -- cgit 1.4.1