3 ms·
FTA: Even in the best circumstances, a program can only acquire one random value this way Can it? let rand = if(fork() == 0) {main as usize} else {std::proc
by Someone 2y ago
FTA: Even in the best circumstances, a program can only acquire one random value this way
Can it?
let rand = if(fork() == 0) {main as usize} else {std::process::exit(0)}
(For those who wonder: I know this code has ‘some’ issues)
- deathanatos 2y agoWould fork() alone cause another ASLR roll? I feel like if fork just forks — duplicates the memory space & execution, with all the pages being CoW — the layout of the child is going to be the same as the parent. Ran the slightly modified: fn main() { if fork() == 0 { dbg!(main as usize); } else { dbg!(main as usize); } } which got me, [src/main.rs:7:9] main as usize = 105397413561856 [src/main.rs:5:9] main as usize = 105397413561856
- mike_hock 2y ago> Would fork() alone cause another ASLR roll? No, that's fundamentally impossible.
- sim7c00 2y agomaybe execve. the loader/linker (ld in linux) are responsible for loading the address. I think with fork they are not re-loaded but it copies (clones page tables/pages etc?) the addr space. Also, if you print your addrs in hex: '0x5fdbbf654600' you can see its aligned to some place. if you'd do number >> 8 it will be '0x005fdbbf6546' which might be more useful if you don't want the least significant bits to be all unset in your random value.