Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Would 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


maybe 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.


> Would fork() alone cause another ASLR roll?

No, that's fundamentally impossible.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: