Re: AMD64 14.0-CURRENT memory layout changes

From: Paul Floyd <paulf2718_at_gmail.com>
Date: Tue, 18 Oct 2022 11:48:11 UTC
Hi Mark


> Setting kern.elf(64|32).aslr.stack to 0 should restore the old
> behaviour.  It should also be possible to disable this on a per-process
> basis with proccontrol(1), but that doesn't appear to work, i.e., there
> is a bug.  However, all randomization can be disabled this way, try
> "procstat -m aslr -s disable ksh93".


If I turn off all aslr then I do see that the memory map reverts to the 
same layout as I get in 13.1.

But that doesn't solve my problems.

I've also seen that sysctl kern.usrstack is no longer used.

On 13.1 I see

   PID trylock  CALL 
__sysctl(0x7fffffffd310,0x2,0x800267c88,0x7fffffffd328,0,0)
   PID trylock  SCTL  "kern.usrstack"
   PID trylock  RET   __sysctl 0
   PID trylock  CALL  getrlimit(RLIMIT_STACK,0x7fffffffd318)
   PID trylock  RET   getrlimit 0
   PID trylock  CALL  thr_self(0x800a12000)
   PID trylock  RET   thr_self 0
   PID trylock  CALL 
mmap(0x7fffdfffe000,0x1000,0<PROT_NONE>,0x1000<MAP_ANON>,0xffffffff,0)
   PID trylock  RET   mmap 140736951476224/0x7fffdfffe000


But on 14.0

I think that this is the mmap for rtld
  PID trylock  CALL 
mmap(0,0x400000,0x3<PROT_READ|PROT_WRITE>,0x15001002<MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(21)>,0xffffffff,0)
  PID trylock  RET   mmap 34372321280/0x800c00000
  PID trylock  CALL  thr_self(0x800a12000)
  PID trylock  RET   thr_self 0

then straight to mapping the stack

  PID trylock  CALL 
mmap(0x7fffdfffe000,0x1000,0<PROT_NONE>,0x1000<MAP_ANON>,0xffffffff,0)
  PID trylock  RET   mmap 140736951476224/0x7fffdfffe000


How is 14.0 working out what address to use for the stack?
(The above is with ASLR all off)

A+
Paul